euscanwww: Changing RefreshPackageQuery.query to ForeignKey
Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
parent
a6b215cec9
commit
3be52a710c
@ -0,0 +1,191 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import datetime
|
||||||
|
from south.db import db
|
||||||
|
from south.v2 import SchemaMigration
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(SchemaMigration):
|
||||||
|
|
||||||
|
def forwards(self, orm):
|
||||||
|
# Deleting field 'RefreshPackageQuery.query'
|
||||||
|
db.delete_column('djeuscan_refreshpackagequery', 'query')
|
||||||
|
|
||||||
|
# Adding field 'RefreshPackageQuery.package'
|
||||||
|
db.add_column('djeuscan_refreshpackagequery', 'package',
|
||||||
|
self.gf('django.db.models.fields.related.ForeignKey')(to=orm['djeuscan.Package']),
|
||||||
|
keep_default=False)
|
||||||
|
|
||||||
|
def backwards(self, orm):
|
||||||
|
# Adding field 'RefreshPackageQuery.query'
|
||||||
|
db.add_column('djeuscan_refreshpackagequery', 'query',
|
||||||
|
self.gf('django.db.models.fields.CharField')(default=None, max_length=256, unique=True),
|
||||||
|
keep_default=False)
|
||||||
|
|
||||||
|
# Deleting field 'RefreshPackageQuery.package'
|
||||||
|
db.delete_column('djeuscan_refreshpackagequery', 'package_id')
|
||||||
|
|
||||||
|
models = {
|
||||||
|
'auth.group': {
|
||||||
|
'Meta': {'object_name': 'Group'},
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
|
||||||
|
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
|
||||||
|
},
|
||||||
|
'auth.permission': {
|
||||||
|
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
|
||||||
|
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||||
|
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||||
|
},
|
||||||
|
'auth.user': {
|
||||||
|
'Meta': {'object_name': 'User'},
|
||||||
|
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||||
|
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
|
||||||
|
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||||
|
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||||
|
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||||
|
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||||
|
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||||
|
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||||
|
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
|
||||||
|
},
|
||||||
|
'contenttypes.contenttype': {
|
||||||
|
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
|
||||||
|
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||||
|
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
|
||||||
|
},
|
||||||
|
'djeuscan.categoryassociation': {
|
||||||
|
'Meta': {'unique_together': "(['user', 'category'],)", 'object_name': 'CategoryAssociation'},
|
||||||
|
'category': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
|
||||||
|
},
|
||||||
|
'djeuscan.categorylog': {
|
||||||
|
'Meta': {'object_name': 'CategoryLog', '_ormbases': ['djeuscan.Log']},
|
||||||
|
'category': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||||
|
'log_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['djeuscan.Log']", 'unique': 'True', 'primary_key': 'True'})
|
||||||
|
},
|
||||||
|
'djeuscan.euscanresult': {
|
||||||
|
'Meta': {'object_name': 'EuscanResult'},
|
||||||
|
'datetime': ('django.db.models.fields.DateTimeField', [], {}),
|
||||||
|
'ebuild': ('django.db.models.fields.CharField', [], {'max_length': '256', 'blank': 'True'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'package': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['djeuscan.Package']"}),
|
||||||
|
'result': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
|
||||||
|
'scan_time': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'})
|
||||||
|
},
|
||||||
|
'djeuscan.herd': {
|
||||||
|
'Meta': {'object_name': 'Herd'},
|
||||||
|
'email': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}),
|
||||||
|
'herd': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'})
|
||||||
|
},
|
||||||
|
'djeuscan.herdassociation': {
|
||||||
|
'Meta': {'unique_together': "(['user', 'herd'],)", 'object_name': 'HerdAssociation'},
|
||||||
|
'herd': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['djeuscan.Herd']"}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
|
||||||
|
},
|
||||||
|
'djeuscan.herdlog': {
|
||||||
|
'Meta': {'object_name': 'HerdLog', '_ormbases': ['djeuscan.Log']},
|
||||||
|
'herd': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['djeuscan.Herd']"}),
|
||||||
|
'log_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['djeuscan.Log']", 'unique': 'True', 'primary_key': 'True'})
|
||||||
|
},
|
||||||
|
'djeuscan.log': {
|
||||||
|
'Meta': {'object_name': 'Log'},
|
||||||
|
'datetime': ('django.db.models.fields.DateTimeField', [], {}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'n_packages_gentoo': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||||
|
'n_packages_outdated': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||||
|
'n_packages_overlay': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||||
|
'n_versions_gentoo': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||||
|
'n_versions_overlay': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||||
|
'n_versions_upstream': ('django.db.models.fields.IntegerField', [], {'default': '0'})
|
||||||
|
},
|
||||||
|
'djeuscan.maintainer': {
|
||||||
|
'Meta': {'object_name': 'Maintainer'},
|
||||||
|
'email': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'name': ('django.db.models.fields.CharField', [], {'max_length': '128'})
|
||||||
|
},
|
||||||
|
'djeuscan.maintainerassociation': {
|
||||||
|
'Meta': {'unique_together': "(['user', 'maintainer'],)", 'object_name': 'MaintainerAssociation'},
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'maintainer': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['djeuscan.Maintainer']"}),
|
||||||
|
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
|
||||||
|
},
|
||||||
|
'djeuscan.maintainerlog': {
|
||||||
|
'Meta': {'object_name': 'MaintainerLog', '_ormbases': ['djeuscan.Log']},
|
||||||
|
'log_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['djeuscan.Log']", 'unique': 'True', 'primary_key': 'True'}),
|
||||||
|
'maintainer': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['djeuscan.Maintainer']"})
|
||||||
|
},
|
||||||
|
'djeuscan.package': {
|
||||||
|
'Meta': {'unique_together': "(['category', 'name'],)", 'object_name': 'Package'},
|
||||||
|
'category': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||||
|
'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
|
||||||
|
'herds': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['djeuscan.Herd']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||||
|
'homepage': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'last_version_gentoo': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'last_version_gentoo'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['djeuscan.Version']"}),
|
||||||
|
'last_version_overlay': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'last_version_overlay'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['djeuscan.Version']"}),
|
||||||
|
'last_version_upstream': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'last_version_upstream'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['djeuscan.Version']"}),
|
||||||
|
'maintainers': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['djeuscan.Maintainer']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||||
|
'n_overlay': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||||
|
'n_packaged': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||||
|
'n_versions': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||||
|
'name': ('django.db.models.fields.CharField', [], {'max_length': '128'})
|
||||||
|
},
|
||||||
|
'djeuscan.packageassociation': {
|
||||||
|
'Meta': {'unique_together': "(['user', 'package'],)", 'object_name': 'PackageAssociation'},
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'package': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['djeuscan.Package']"}),
|
||||||
|
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
|
||||||
|
},
|
||||||
|
'djeuscan.refreshpackagequery': {
|
||||||
|
'Meta': {'object_name': 'RefreshPackageQuery'},
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'package': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['djeuscan.Package']"}),
|
||||||
|
'priority': ('django.db.models.fields.IntegerField', [], {'default': '0'})
|
||||||
|
},
|
||||||
|
'djeuscan.version': {
|
||||||
|
'Meta': {'unique_together': "(['package', 'slot', 'revision', 'version', 'overlay'],)", 'object_name': 'Version'},
|
||||||
|
'alive': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True'}),
|
||||||
|
'confidence': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||||
|
'handler': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'overlay': ('django.db.models.fields.CharField', [], {'default': "'gentoo'", 'max_length': '128', 'db_index': 'True', 'blank': 'True'}),
|
||||||
|
'package': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['djeuscan.Package']"}),
|
||||||
|
'packaged': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'revision': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||||
|
'slot': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '128', 'blank': 'True'}),
|
||||||
|
'urls': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
|
||||||
|
'version': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||||
|
'version_type': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'})
|
||||||
|
},
|
||||||
|
'djeuscan.versionlog': {
|
||||||
|
'Meta': {'object_name': 'VersionLog'},
|
||||||
|
'action': ('django.db.models.fields.IntegerField', [], {}),
|
||||||
|
'datetime': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'overlay': ('django.db.models.fields.CharField', [], {'default': "'gentoo'", 'max_length': '128', 'blank': 'True'}),
|
||||||
|
'package': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['djeuscan.Package']"}),
|
||||||
|
'packaged': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'revision': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||||
|
'slot': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '128', 'blank': 'True'}),
|
||||||
|
'version': ('django.db.models.fields.CharField', [], {'max_length': '128'})
|
||||||
|
},
|
||||||
|
'djeuscan.worldlog': {
|
||||||
|
'Meta': {'object_name': 'WorldLog', '_ormbases': ['djeuscan.Log']},
|
||||||
|
'log_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['djeuscan.Log']", 'unique': 'True', 'primary_key': 'True'})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
complete_apps = ['djeuscan']
|
@ -269,11 +269,11 @@ class MaintainerLog(Log):
|
|||||||
|
|
||||||
|
|
||||||
class RefreshPackageQuery(models.Model):
|
class RefreshPackageQuery(models.Model):
|
||||||
query = models.CharField(max_length=255, unique=True)
|
package = models.ForeignKey(Package)
|
||||||
priority = models.IntegerField(default=0)
|
priority = models.IntegerField(default=0)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return u'[%d] %s' % (self.priority, self.query)
|
return u'[%d] %s' % (self.priority, self.package)
|
||||||
|
|
||||||
|
|
||||||
class HerdAssociation(models.Model):
|
class HerdAssociation(models.Model):
|
||||||
|
@ -200,8 +200,7 @@ class ScanPortage(object):
|
|||||||
obj, created = Package.objects.get_or_create(
|
obj, created = Package.objects.get_or_create(
|
||||||
category=cat,
|
category=cat,
|
||||||
name=pkg,
|
name=pkg,
|
||||||
homepage=homepage,
|
defaults={"homepage": homepage, "description": description},
|
||||||
description=description,
|
|
||||||
)
|
)
|
||||||
self.cache_store_package(obj)
|
self.cache_store_package(obj)
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ def consume_refresh_package_request():
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
return {}
|
return {}
|
||||||
else:
|
else:
|
||||||
result = scan_package_task(obj.query)
|
result = scan_package_task(obj.package)
|
||||||
obj.delete()
|
obj.delete()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
{{ package.category }}/{{ package.name }}
|
{{ package.category }}/{{ package.name }}
|
||||||
|
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
<button class="btn refresh-button" data-package="{{ package.category }}/{{ package.name }}">
|
<button class="btn refresh-button" data-category="{{ package.category }}" data-package="{{ package.name }}">
|
||||||
Refresh
|
Refresh
|
||||||
</button>
|
</button>
|
||||||
<button class="btn favourite-button {% if favourited %}hide{% endif %}" data-url="{% url "favourite_package" package.category package.name %}">
|
<button class="btn favourite-button {% if favourited %}hide{% endif %}" data-url="{% url "favourite_package" package.category package.name %}">
|
||||||
@ -146,8 +146,9 @@
|
|||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(".refresh-button").click(function() {
|
$(".refresh-button").click(function() {
|
||||||
var url = "{% url "refresh_package" "x/x" %}";
|
var url = "{% url "refresh_package" "XXX" "YYY" %}";
|
||||||
$.post(url.replace("x/x", $(this).data("package")), function() {
|
$.post(url.replace("XXX", $(this).data("category")).replace("YYY", $(this).data("package")),
|
||||||
|
function() {
|
||||||
alert("Submitted!");
|
alert("Submitted!");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -19,8 +19,9 @@ package_patterns = patterns('djeuscan.views',
|
|||||||
url(r'^(?P<category>[\w+][\w+.-]*)/(?P<package>[\w+][\w+.-]*)/favourite$',
|
url(r'^(?P<category>[\w+][\w+.-]*)/(?P<package>[\w+][\w+.-]*)/favourite$',
|
||||||
'favourite_package', name="favourite_package"),
|
'favourite_package', name="favourite_package"),
|
||||||
url((r'^(?P<category>[\w+][\w+.-]*)/(?P<package>[\w+][\w+.-]*)/'
|
url((r'^(?P<category>[\w+][\w+.-]*)/(?P<package>[\w+][\w+.-]*)/'
|
||||||
'unfavourite$'),
|
'unfavourite$'), 'unfavourite_package', name="unfavourite_package"),
|
||||||
'unfavourite_package', name="unfavourite_package"),
|
url((r'^(?P<category>[\w+][\w+.-]*)/(?P<package>[\w+][\w+.-]*)/'
|
||||||
|
'refresh$'), "refresh_package", name="refresh_package"),
|
||||||
)
|
)
|
||||||
|
|
||||||
categories_patterns = patterns('djeuscan.views',
|
categories_patterns = patterns('djeuscan.views',
|
||||||
@ -68,9 +69,6 @@ overlays_patterns = patterns('djeuscan.views',
|
|||||||
)
|
)
|
||||||
|
|
||||||
tasks_patterns = patterns('djeuscan.views',
|
tasks_patterns = patterns('djeuscan.views',
|
||||||
url(r'^refresh_package/(?P<query>(?:[\w+][\w+.-]*/[\w+][\w+.-]*))/$',
|
|
||||||
"refresh_package",
|
|
||||||
name="refresh_package"),
|
|
||||||
url(r'^registered_tasks/$', admin_required(registered_tasks),
|
url(r'^registered_tasks/$', admin_required(registered_tasks),
|
||||||
name="registered_tasks"),
|
name="registered_tasks"),
|
||||||
url(r'^apply/(?P<task_name>.*)/$', admin_required(apply_task),
|
url(r'^apply/(?P<task_name>.*)/$', admin_required(apply_task),
|
||||||
|
@ -292,8 +292,10 @@ def registered_tasks(request):
|
|||||||
@login_required
|
@login_required
|
||||||
@require_POST
|
@require_POST
|
||||||
@ajax_request
|
@ajax_request
|
||||||
def refresh_package(request, query):
|
def refresh_package(request, category, package):
|
||||||
obj, created = RefreshPackageQuery.objects.get_or_create(query=query)
|
pkg = get_object_or_404(Package, category=category, name=package)
|
||||||
|
|
||||||
|
obj, created = RefreshPackageQuery.objects.get_or_create(package=pkg)
|
||||||
if not created:
|
if not created:
|
||||||
obj.priority += 1
|
obj.priority += 1
|
||||||
obj.save()
|
obj.save()
|
||||||
|
Loading…
Reference in New Issue
Block a user