diff --git a/euscanwww/djeuscan/admin.py b/euscanwww/djeuscan/admin.py index 329117a..cec9244 100644 --- a/euscanwww/djeuscan/admin.py +++ b/euscanwww/djeuscan/admin.py @@ -1,5 +1,7 @@ from djeuscan.models import Package, Version, VersionLog, EuscanResult, \ - Log, WorldLog, CategoryLog, HerdLog, MaintainerLog, Herd, Maintainer + Log, WorldLog, CategoryLog, HerdLog, MaintainerLog, Herd, Maintainer, \ + RefreshPackageQuery, HerdAssociation, CategoryAssociation, \ + MaintainerAssociation, PackageAssociation from django.contrib import admin @@ -44,3 +46,9 @@ admin.site.register(WorldLog) admin.site.register(CategoryLog) admin.site.register(HerdLog) admin.site.register(MaintainerLog) + +admin.site.register(RefreshPackageQuery) +admin.site.register(HerdAssociation) +admin.site.register(CategoryAssociation) +admin.site.register(MaintainerAssociation) +admin.site.register(PackageAssociation) diff --git a/euscanwww/djeuscan/managers.py b/euscanwww/djeuscan/managers.py index 2172602..0d4c544 100644 --- a/euscanwww/djeuscan/managers.py +++ b/euscanwww/djeuscan/managers.py @@ -35,7 +35,6 @@ ANNOTATE_DICT = {name: models.Sum(name) class PackageMixin(object): - for_maintainer = _gen_for_function('maintainers') for_herd = _gen_for_function('herds') for_category = _gen_for_function('category') diff --git a/euscanwww/djeuscan/migrations/0004_auto__add_categoryassociation__add_unique_categoryassociation_user_cat.py b/euscanwww/djeuscan/migrations/0004_auto__add_categoryassociation__add_unique_categoryassociation_user_cat.py new file mode 100644 index 0000000..888fefa --- /dev/null +++ b/euscanwww/djeuscan/migrations/0004_auto__add_categoryassociation__add_unique_categoryassociation_user_cat.py @@ -0,0 +1,238 @@ +# -*- 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): + # Adding model 'CategoryAssociation' + db.create_table('djeuscan_categoryassociation', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])), + ('category', self.gf('django.db.models.fields.CharField')(max_length=128)), + )) + db.send_create_signal('djeuscan', ['CategoryAssociation']) + + # Adding unique constraint on 'CategoryAssociation', fields ['user', 'category'] + db.create_unique('djeuscan_categoryassociation', ['user_id', 'category']) + + # Adding model 'PackageAssociation' + db.create_table('djeuscan_packageassociation', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])), + ('package', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['djeuscan.Package'])), + )) + db.send_create_signal('djeuscan', ['PackageAssociation']) + + # Adding unique constraint on 'PackageAssociation', fields ['user', 'package'] + db.create_unique('djeuscan_packageassociation', ['user_id', 'package_id']) + + # Adding model 'HerdAssociation' + db.create_table('djeuscan_herdassociation', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])), + ('herd', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['djeuscan.Herd'])), + )) + db.send_create_signal('djeuscan', ['HerdAssociation']) + + # Adding unique constraint on 'HerdAssociation', fields ['user', 'herd'] + db.create_unique('djeuscan_herdassociation', ['user_id', 'herd_id']) + + # Adding model 'MaintainerAssociation' + db.create_table('djeuscan_maintainerassociation', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'])), + ('maintainer', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['djeuscan.Maintainer'])), + )) + db.send_create_signal('djeuscan', ['MaintainerAssociation']) + + # Adding unique constraint on 'MaintainerAssociation', fields ['user', 'maintainer'] + db.create_unique('djeuscan_maintainerassociation', ['user_id', 'maintainer_id']) + + def backwards(self, orm): + # Removing unique constraint on 'MaintainerAssociation', fields ['user', 'maintainer'] + db.delete_unique('djeuscan_maintainerassociation', ['user_id', 'maintainer_id']) + + # Removing unique constraint on 'HerdAssociation', fields ['user', 'herd'] + db.delete_unique('djeuscan_herdassociation', ['user_id', 'herd_id']) + + # Removing unique constraint on 'PackageAssociation', fields ['user', 'package'] + db.delete_unique('djeuscan_packageassociation', ['user_id', 'package_id']) + + # Removing unique constraint on 'CategoryAssociation', fields ['user', 'category'] + db.delete_unique('djeuscan_categoryassociation', ['user_id', 'category']) + + # Deleting model 'CategoryAssociation' + db.delete_table('djeuscan_categoryassociation') + + # Deleting model 'PackageAssociation' + db.delete_table('djeuscan_packageassociation') + + # Deleting model 'HerdAssociation' + db.delete_table('djeuscan_herdassociation') + + # Deleting model 'MaintainerAssociation' + db.delete_table('djeuscan_maintainerassociation') + + 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', [], {}), + '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'}) + }, + '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'}), + 'priority': ('django.db.models.fields.IntegerField', [], {'default': '0'}), + 'query': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '256'}) + }, + 'djeuscan.version': { + 'Meta': {'unique_together': "(['package', 'slot', 'revision', 'version', 'overlay'],)", 'object_name': 'Version'}, + 'alive': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': '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'}) + }, + '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'] \ No newline at end of file diff --git a/euscanwww/djeuscan/models.py b/euscanwww/djeuscan/models.py index 85a0c4a..936b2fc 100644 --- a/euscanwww/djeuscan/models.py +++ b/euscanwww/djeuscan/models.py @@ -2,6 +2,8 @@ from django.db import models from django.core.validators import RegexValidator, validate_email, URLValidator from django.core.exceptions import ValidationError +from django.contrib.auth.models import User + from djeuscan.managers import PackageManager, VersionLogManager, \ EuscanResultManager @@ -268,3 +270,47 @@ class RefreshPackageQuery(models.Model): def __unicode__(self): return u'[%d] %s' % (self.priority, self.query) + + +class HerdAssociation(models.Model): + user = models.ForeignKey(User) + herd = models.ForeignKey(Herd) + + class Meta: + unique_together = ['user', 'herd'] + + def __unicode__(self): + return u'[%s] %s' % (self.user, self.herd) + + +class MaintainerAssociation(models.Model): + user = models.ForeignKey(User) + maintainer = models.ForeignKey(Maintainer) + + class Meta: + unique_together = ['user', 'maintainer'] + + def __unicode__(self): + return u'[%s] %s' % (self.user, self.maintainer) + + +class PackageAssociation(models.Model): + user = models.ForeignKey(User) + package = models.ForeignKey(Package) + + class Meta: + unique_together = ['user', 'package'] + + def __unicode__(self): + return u'[%s] %s' % (self.user, self.package) + + +class CategoryAssociation(models.Model): + user = models.ForeignKey(User) + category = models.CharField(max_length=128, validators=[validate_category]) + + class Meta: + unique_together = ['user', 'category'] + + def __unicode__(self): + return u'[%s] %s' % (self.user, self.category) diff --git a/euscanwww/djeuscan/templates/_base.html b/euscanwww/djeuscan/templates/_base.html index 052abd0..afd9324 100644 --- a/euscanwww/djeuscan/templates/_base.html +++ b/euscanwww/djeuscan/templates/_base.html @@ -37,12 +37,25 @@
  • Overlays
  • Scan World
  • Statistics
  • - + + {% if user.is_authenticated %} +
  • {{ user }}'s profile
  • + +
  • Logout
  • + {% else %} +
  • Login
  • +
  • Register
  • + {% endif %} +
  • ---
  • + {% block menu_feed %}
  • feed @@ -52,15 +65,6 @@
  • ---
  • API
  • About
  • -
  • ---
  • - - {% if user.is_authenticated %} -
  • Welcome {{ user }}
  • -
  • Logout
  • - {% else %} -
  • Login
  • -
  • Register
  • - {% endif %} {% endblock %} diff --git a/euscanwww/djeuscan/templates/euscan/accounts/categories.html b/euscanwww/djeuscan/templates/euscan/accounts/categories.html new file mode 100644 index 0000000..a2bd6fa --- /dev/null +++ b/euscanwww/djeuscan/templates/euscan/accounts/categories.html @@ -0,0 +1,11 @@ +{% extends "_base.html" %} +{% load url from future %} + +{% block title %} + {{ block.super }} - My categories +{% endblock %} + + +{% block content %} +

    Welcome {{ user }}

    +{% endblock %} diff --git a/euscanwww/djeuscan/templates/euscan/accounts/herds.html b/euscanwww/djeuscan/templates/euscan/accounts/herds.html new file mode 100644 index 0000000..d77aa03 --- /dev/null +++ b/euscanwww/djeuscan/templates/euscan/accounts/herds.html @@ -0,0 +1,11 @@ +{% extends "_base.html" %} +{% load url from future %} + +{% block title %} + {{ block.super }} - My herds +{% endblock %} + + +{% block content %} +

    Welcome {{ user }}

    +{% endblock %} diff --git a/euscanwww/djeuscan/templates/euscan/accounts/index.html b/euscanwww/djeuscan/templates/euscan/accounts/index.html new file mode 100644 index 0000000..46ba5c7 --- /dev/null +++ b/euscanwww/djeuscan/templates/euscan/accounts/index.html @@ -0,0 +1,11 @@ +{% extends "_base.html" %} +{% load url from future %} + +{% block title %} + {{ block.super }} - Welcome {{ user }} +{% endblock %} + + +{% block content %} +

    Welcome {{ user }}

    +{% endblock %} diff --git a/euscanwww/djeuscan/templates/euscan/accounts/maintainers.html b/euscanwww/djeuscan/templates/euscan/accounts/maintainers.html new file mode 100644 index 0000000..1a907b9 --- /dev/null +++ b/euscanwww/djeuscan/templates/euscan/accounts/maintainers.html @@ -0,0 +1,11 @@ +{% extends "_base.html" %} +{% load url from future %} + +{% block title %} + {{ block.super }} - My maintainer profiles +{% endblock %} + + +{% block content %} +

    Welcome {{ user }}

    +{% endblock %} diff --git a/euscanwww/djeuscan/templates/euscan/accounts/packages.html b/euscanwww/djeuscan/templates/euscan/accounts/packages.html new file mode 100644 index 0000000..7c847f6 --- /dev/null +++ b/euscanwww/djeuscan/templates/euscan/accounts/packages.html @@ -0,0 +1,16 @@ +{% extends "euscan/_datatable.html" %} +{% load url from future %} + +{% load packages %} + +{% block title %} + {{ block.super }} - My packages +{% endblock %} + + +{% block content %} +

    My Packages

    + + {% packages packages %} + +{% endblock %} diff --git a/euscanwww/djeuscan/templates/euscan/package.html b/euscanwww/djeuscan/templates/euscan/package.html index f042d04..6eb500f 100644 --- a/euscanwww/djeuscan/templates/euscan/package.html +++ b/euscanwww/djeuscan/templates/euscan/package.html @@ -27,10 +27,13 @@

    {{ package.category }}/{{ package.name }} - {% if user.is_superuser %} + {% if user.is_authenticated %} + {% endif %}

    @@ -145,6 +148,12 @@ alert("Submitted!"); }); }); + + $(".favourite-button").click(function() { + $.post($(this).data("url"), function() { + alert("Favourited!"); + }); + }); {% endblock %} diff --git a/euscanwww/djeuscan/urls.py b/euscanwww/djeuscan/urls.py index 31732b4..17063b6 100644 --- a/euscanwww/djeuscan/urls.py +++ b/euscanwww/djeuscan/urls.py @@ -1,7 +1,7 @@ from django.conf.urls.defaults import url, patterns, include from django.contrib.auth.decorators import user_passes_test -from djcelery.views import apply +from djcelery.views import apply as apply_task from djeuscan.views import registered_tasks from djeuscan.feeds import PackageFeed, CategoryFeed, HerdFeed, \ @@ -16,6 +16,8 @@ package_patterns = patterns('djeuscan.views', PackageFeed(), name='package_feed'), url(r'^(?P[\w+][\w+.-]*)/(?P[\w+][\w+.-]*)/$', 'package', name="package"), + url(r'^(?P[\w+][\w+.-]*)/(?P[\w+][\w+.-]*)/favourite$', + 'favourite_package', name="favourite_package"), ) categories_patterns = patterns('djeuscan.views', @@ -25,6 +27,8 @@ categories_patterns = patterns('djeuscan.views', name='category_feed'), url(r'^(?P[\w+][\w+.-]*)/charts/(?P[\w\-]+).png$', 'chart_category', name="chart_category"), + url(r'^(?P[\w+][\w+.-]*)/favourite$', + 'favourite_category', name="favourite_category"), url(r'^$', 'categories', name="categories"), ) @@ -33,6 +37,8 @@ herds_patterns = patterns('djeuscan.views', url(r'^(?P[\@\{\}\w+.-]*)/feed/$', HerdFeed(), name='herd_feed'), url(r'^(?P[\@\{\}\w+.-]*)/charts/(?P[\w\-]+).png$', 'chart_herd', name="chart_herd"), + url(r'^(?P[\@\{\}\w+.-]*)/favourite$', 'favourite_herd', + name="favourite_herd"), url(r'^$', 'herds', name="herds"), ) @@ -42,6 +48,8 @@ maintainers_patterns = patterns('djeuscan.views', name='maintainer_feed'), url(r'^(?P\d+)/charts/(?P[\w\-]+).png$', 'chart_maintainer', name="chart_maintainer"), + url(r'^(?P\d+)/favourite$', + 'favourite_maintainer', name="favourite_maintainer"), url(r'^$', 'maintainers', name="maintainers"), ) @@ -56,10 +64,20 @@ tasks_patterns = patterns('djeuscan.views', name="refresh_package"), url(r'^registered_tasks/$', admin_required(registered_tasks), name="registered_tasks"), - url(r'^apply/(?P.*)/$', admin_required(apply), + url(r'^apply/(?P.*)/$', admin_required(apply_task), name="apply_task"), ) +accounts_patterns = patterns('djeuscan.views', + url(r'^profile/$', 'accounts_index', name="accounts_index"), + url(r'^categories/$', 'accounts_categories', name="accounts_categories"), + url(r'^herds/$', 'accounts_herds', name="accounts_herds"), + url(r'^maintainers/$', 'accounts_maintainers', + name="accounts_maintainers"), + url(r'^packages/$', 'accounts_packages', name="accounts_packages"), +) + + urlpatterns = patterns('djeuscan.views', # Global stuff url(r'^api/', include('djeuscan.api.urls')), @@ -79,5 +97,7 @@ urlpatterns = patterns('djeuscan.views', url(r'^maintainers/', include(maintainers_patterns)), url(r'^overlays/', include(overlays_patterns)), url(r'^package/', include(package_patterns)), + url(r'^tasks/', include(tasks_patterns)), + url(r'^accounts/', include(accounts_patterns)), ) diff --git a/euscanwww/djeuscan/views.py b/euscanwww/djeuscan/views.py index 2492e72..7a34271 100644 --- a/euscanwww/djeuscan/views.py +++ b/euscanwww/djeuscan/views.py @@ -10,7 +10,8 @@ from django.views.decorators.http import require_POST from djeuscan.helpers import version_key, packages_from_names from djeuscan.models import Version, Package, Herd, Maintainer, EuscanResult, \ - VersionLog, RefreshPackageQuery + VersionLog, RefreshPackageQuery, HerdAssociation, MaintainerAssociation, \ + CategoryAssociation, PackageAssociation from djeuscan.forms import WorldForm, PackagesForm from djeuscan.tasks import admin_tasks from djeuscan import charts @@ -287,3 +288,83 @@ def refresh_package(request, query): obj.priority += 1 obj.save() return {"result": "success"} + + +@login_required +@render_to('euscan/accounts/index.html') +def accounts_index(request): + return {} + + +@login_required +@render_to('euscan/accounts/categories.html') +def accounts_categories(request): + return {} + + +@login_required +@render_to('euscan/accounts/herds.html') +def accounts_herds(request): + return {} + + +@login_required +@render_to('euscan/accounts/maintainers.html') +def accounts_maintainers(request): + return {} + + +@login_required +@render_to('euscan/accounts/packages.html') +def accounts_packages(request): + packages = [obj.package for obj in + PackageAssociation.objects.filter(user=request.user)] + return {"packages": packages} + + +@login_required +@require_POST +@ajax_request +def favourite_package(request, category, package): + obj = get_object_or_404(Package, category=category, name=package) + _, created = PackageAssociation.objects.get_or_create( + user=request.user, package=obj + ) + return {"success": created} + + +@login_required +@require_POST +@ajax_request +def favourite_herd(request, herd): + obj = get_object_or_404(Herd, herd=herd) + _, created = HerdAssociation.objects.get_or_create( + user=request.user, herd=obj + ) + return {"success": created} + + +@login_required +@require_POST +@ajax_request +def favourite_maintainer(request, maintainer_id): + obj = get_object_or_404(Maintainer, pk=maintainer_id) + _, created = MaintainerAssociation.objects.get_or_create( + user=request.user, maintainer=obj + ) + return {"success": created} + + +@login_required +@require_POST +@ajax_request +def favourite_category(request, category): + packages = Package.objects.for_category(category, last_versions=True) + + if not packages: + raise Http404 + + _, created = CategoryAssociation.objects.get_or_create( + user=request.user, category=category + ) + return {"success": created} diff --git a/euscanwww/htdocs/css/style.css b/euscanwww/htdocs/css/style.css index 7ac69a3..62d6cda 100644 --- a/euscanwww/htdocs/css/style.css +++ b/euscanwww/htdocs/css/style.css @@ -87,10 +87,13 @@ a:hover, a:active color: #fff; } -.menu li -{ - list-style-type: none; - } +.menu li { + list-style-type: none; +} + +.submenu { + padding-left: 15px; +} .menu dl { margin-left: 15px;