euscanwww: Adding more options to preferences, implementing more filters for feeds

Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
volpino 2012-08-11 13:31:57 +02:00
parent f04f28aacc
commit 1bb4f14faa
10 changed files with 438 additions and 28 deletions

View File

@ -1,6 +1,6 @@
from djeuscan.models import Package, Version, VersionLog, EuscanResult, \ from djeuscan.models import Package, Version, VersionLog, EuscanResult, \
Log, WorldLog, CategoryLog, HerdLog, MaintainerLog, Herd, Maintainer, \ Log, WorldLog, CategoryLog, HerdLog, MaintainerLog, Herd, Maintainer, \
RefreshPackageQuery, Category, Overlay, ProblemReport RefreshPackageQuery, Category, Overlay, ProblemReport, UserProfile
from django.contrib import admin from django.contrib import admin
@ -36,6 +36,9 @@ class ProblemReportAdmin(admin.ModelAdmin):
list_filter = ('datetime', 'package__category') list_filter = ('datetime', 'package__category')
ordering = ["-datetime"] ordering = ["-datetime"]
admin.site.register(UserProfile)
admin.site.register(Package, PackageAdmin) admin.site.register(Package, PackageAdmin)
admin.site.register(Herd, HerdAdmin) admin.site.register(Herd, HerdAdmin)

View File

@ -1,9 +1,13 @@
import json
from django.contrib.syndication.views import Feed, FeedDoesNotExist from django.contrib.syndication.views import Feed, FeedDoesNotExist
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.utils.feedgenerator import Atom1Feed from django.utils.feedgenerator import Atom1Feed
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.db.models import Q from django.db.models import Q
from euscan.version import gentoo_unstable
from djeuscan.models import Package, Herd, Maintainer, VersionLog from djeuscan.models import Package, Herd, Maintainer, VersionLog
from djeuscan.helpers import get_profile, get_account_packages from djeuscan.helpers import get_profile, get_account_packages
@ -50,19 +54,29 @@ class BaseFeed(Feed):
def items(self, data=None): def items(self, data=None):
user = data.get("user", None) if data else None user = data.get("user", None) if data else None
options = data.get("options", None) if data else None options = data.get("options", {}) if data else {}
upstream_info = True
portage_info = True
# first of all consider options, then user preferences # first of all consider options, then user preferences
if options: try:
upstream_info = "upstream_info" in options upstream_info = json.loads(options.get("upstream_info", "1"))
portage_info = "portage_info" in options portage_info = json.loads(options.get("portage_info", "1"))
elif user: show_adds = json.loads(options.get("show_adds", "1"))
show_removals = json.loads(options.get("show_removals", "1"))
ignore_pre = json.loads(options.get("ignore_pre", "0"))
ignore_pre_if_stable = json.loads(
options.get("ignore_pre_if_stable", "0")
)
except ValueError:
return []
if user and not options:
profile = get_profile(user) profile = get_profile(user)
upstream_info = profile.upstream_info upstream_info = profile.feed_upstream_info
portage_info = profile.portage_info portage_info = profile.feed_portage_info
show_adds = profile.feed_show_adds
show_removals = profile.feed_show_removals
ignore_pre = profile.feed_ignore_pre
ignore_pre_if_stable = profile.feed_ignore_pre_if_stable
ret, max_items = self._items(data) ret, max_items = self._items(data)
@ -70,6 +84,17 @@ class BaseFeed(Feed):
ret = ret.exclude(overlay="") ret = ret.exclude(overlay="")
if not portage_info: if not portage_info:
ret = ret.exclude(~Q(overlay="")) ret = ret.exclude(~Q(overlay=""))
if not show_adds:
ret = ret.exclude(action=VersionLog.VERSION_ADDED)
if not show_removals:
ret = ret.exclude(action=VersionLog.VERSION_REMOVED)
if ignore_pre:
ret = ret.exclude(vtype__in=gentoo_unstable)
if ignore_pre_if_stable:
ret = ret.exclude(
~Q(package__last_version_gentoo__vtype__in=gentoo_unstable),
vtype__in=gentoo_unstable
)
return ret.order_by("-datetime")[:max_items] return ret.order_by("-datetime")[:max_items]

View File

@ -34,5 +34,28 @@ class PreferencesForm(forms.Form):
last_name = forms.CharField(max_length=30, required=False) last_name = forms.CharField(max_length=30, required=False)
email = forms.EmailField() email = forms.EmailField()
upstream_info = forms.BooleanField(required=False) feed_upstream_info = forms.BooleanField(required=False,
portage_info = forms.BooleanField(required=False) label="Upstream info")
feed_portage_info = forms.BooleanField(required=False,
label="Portage info")
feed_show_adds = forms.BooleanField(required=False,
label="Show version bumps")
feed_show_removals = forms.BooleanField(required=False,
label="Show version removals")
feed_ignore_pre = forms.BooleanField(required=False,
label="Ignore unstable releases")
feed_ignore_pre_if_stable = forms.BooleanField(
required=False,
label="Ignore unstable releases if current version is stable"
)
email_activated = forms.BooleanField(
required=False, label="Receive euscan emails"
)
email_ignore_pre = forms.BooleanField(
required=False, label="Ignore unstable releases"
)
email_ignore_pre_if_stable = forms.BooleanField(
required=False,
label="Ignore unstable releases if current version is stable"
)

View File

@ -0,0 +1,282 @@
# -*- 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 'UserProfile.portage_info'
db.delete_column('djeuscan_userprofile', 'portage_info')
# Deleting field 'UserProfile.upstream_info'
db.delete_column('djeuscan_userprofile', 'upstream_info')
# Adding field 'UserProfile.feed_upstream_info'
db.add_column('djeuscan_userprofile', 'feed_upstream_info',
self.gf('django.db.models.fields.BooleanField')(default=True),
keep_default=False)
# Adding field 'UserProfile.feed_portage_info'
db.add_column('djeuscan_userprofile', 'feed_portage_info',
self.gf('django.db.models.fields.BooleanField')(default=False),
keep_default=False)
# Adding field 'UserProfile.feed_show_adds'
db.add_column('djeuscan_userprofile', 'feed_show_adds',
self.gf('django.db.models.fields.BooleanField')(default=True),
keep_default=False)
# Adding field 'UserProfile.feed_show_removals'
db.add_column('djeuscan_userprofile', 'feed_show_removals',
self.gf('django.db.models.fields.BooleanField')(default=True),
keep_default=False)
# Adding field 'UserProfile.feed_ignore_pre'
db.add_column('djeuscan_userprofile', 'feed_ignore_pre',
self.gf('django.db.models.fields.BooleanField')(default=False),
keep_default=False)
# Adding field 'UserProfile.feed_ignore_pre_if_stable'
db.add_column('djeuscan_userprofile', 'feed_ignore_pre_if_stable',
self.gf('django.db.models.fields.BooleanField')(default=False),
keep_default=False)
# Adding field 'UserProfile.email_activated'
db.add_column('djeuscan_userprofile', 'email_activated',
self.gf('django.db.models.fields.BooleanField')(default=True),
keep_default=False)
# Adding field 'UserProfile.email_ignore_pre'
db.add_column('djeuscan_userprofile', 'email_ignore_pre',
self.gf('django.db.models.fields.BooleanField')(default=False),
keep_default=False)
# Adding field 'UserProfile.email_ignore_pre_if_stable'
db.add_column('djeuscan_userprofile', 'email_ignore_pre_if_stable',
self.gf('django.db.models.fields.BooleanField')(default=False),
keep_default=False)
def backwards(self, orm):
# Adding field 'UserProfile.portage_info'
db.add_column('djeuscan_userprofile', 'portage_info',
self.gf('django.db.models.fields.BooleanField')(default=False),
keep_default=False)
# Adding field 'UserProfile.upstream_info'
db.add_column('djeuscan_userprofile', 'upstream_info',
self.gf('django.db.models.fields.BooleanField')(default=True),
keep_default=False)
# Deleting field 'UserProfile.feed_upstream_info'
db.delete_column('djeuscan_userprofile', 'feed_upstream_info')
# Deleting field 'UserProfile.feed_portage_info'
db.delete_column('djeuscan_userprofile', 'feed_portage_info')
# Deleting field 'UserProfile.feed_show_adds'
db.delete_column('djeuscan_userprofile', 'feed_show_adds')
# Deleting field 'UserProfile.feed_show_removals'
db.delete_column('djeuscan_userprofile', 'feed_show_removals')
# Deleting field 'UserProfile.feed_ignore_pre'
db.delete_column('djeuscan_userprofile', 'feed_ignore_pre')
# Deleting field 'UserProfile.feed_ignore_pre_if_stable'
db.delete_column('djeuscan_userprofile', 'feed_ignore_pre_if_stable')
# Deleting field 'UserProfile.email_activated'
db.delete_column('djeuscan_userprofile', 'email_activated')
# Deleting field 'UserProfile.email_ignore_pre'
db.delete_column('djeuscan_userprofile', 'email_ignore_pre')
# Deleting field 'UserProfile.email_ignore_pre_if_stable'
db.delete_column('djeuscan_userprofile', 'email_ignore_pre_if_stable')
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.category': {
'Meta': {'object_name': 'Category'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128'})
},
'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'}),
'maintainers': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['djeuscan.Maintainer']", 'symmetrical': 'False'})
},
'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.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.overlay': {
'Meta': {'object_name': 'Overlay'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128'})
},
'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.problemreport': {
'Meta': {'object_name': 'ProblemReport'},
'datetime': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'message': ('django.db.models.fields.TextField', [], {}),
'package': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['djeuscan.Package']"}),
'subject': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
'version': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['djeuscan.Version']", 'null': 'True', 'blank': 'True'})
},
'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'}),
'users': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.User']", 'symmetrical': 'False'})
},
'djeuscan.userprofile': {
'Meta': {'object_name': 'UserProfile'},
'categories': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['djeuscan.Category']", 'symmetrical': 'False'}),
'email_activated': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'email_ignore_pre': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'email_ignore_pre_if_stable': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'feed_ignore_pre': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'feed_ignore_pre_if_stable': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'feed_portage_info': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'feed_show_adds': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'feed_show_removals': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'feed_upstream_info': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
'herds': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['djeuscan.Herd']", 'symmetrical': 'False'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'maintainers': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['djeuscan.Maintainer']", 'symmetrical': 'False'}),
'overlays': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['djeuscan.Overlay']", 'symmetrical': 'False'}),
'packages': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['djeuscan.Package']", 'symmetrical': 'False'}),
'user': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.User']", 'unique': 'True'})
},
'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'}),
'ebuild_path': ('django.db.models.fields.CharField', [], {'max_length': '256', 'blank': 'True'}),
'handler': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'metadata_path': ('django.db.models.fields.CharField', [], {'max_length': '256', 'blank': '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'}),
'vtype': ('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'}),
'vtype': ('django.db.models.fields.CharField', [], {'max_length': '128', 'blank': 'True'})
},
'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']

View File

@ -259,8 +259,16 @@ class UserProfile(models.Model):
categories = models.ManyToManyField(Category) categories = models.ManyToManyField(Category)
overlays = models.ManyToManyField(Overlay) overlays = models.ManyToManyField(Overlay)
upstream_info = models.BooleanField(default=True) feed_upstream_info = models.BooleanField(default=True)
portage_info = models.BooleanField(default=False) feed_portage_info = models.BooleanField(default=False)
feed_show_adds = models.BooleanField(default=True)
feed_show_removals = models.BooleanField(default=True)
feed_ignore_pre = models.BooleanField(default=False)
feed_ignore_pre_if_stable = models.BooleanField(default=False)
email_activated = models.BooleanField(default=True)
email_ignore_pre = models.BooleanField(default=False)
email_ignore_pre_if_stable = models.BooleanField(default=False)
class Log(models.Model): class Log(models.Model):

View File

@ -316,7 +316,8 @@ class ScanPortage(object):
slot=version.slot, slot=version.slot,
revision=version.revision, revision=version.revision,
version=version.version, version=version.version,
overlay=version.overlay overlay=version.overlay,
vtype=version.vtype,
) )
versions.delete() versions.delete()

View File

@ -113,7 +113,8 @@ class ScanUpstream(object):
slot='', slot='',
revision='r0', revision='r0',
version=ver, version=ver,
overlay='' overlay='',
vtype=version_type,
) )
package.n_versions += 1 package.n_versions += 1
@ -131,7 +132,8 @@ class ScanUpstream(object):
slot=version.slot, slot=version.slot,
revision=version.revision, revision=version.revision,
version=version.version, version=version.version,
overlay=version.overlay overlay=version.overlay,
vtype=version.vtype,
) )
version.package.n_versions -= 1 version.package.n_versions -= 1

View File

@ -31,11 +31,68 @@
<form id="preferences_form" method='post' action='.'> <form id="preferences_form" method='post' action='.'>
{% csrf_token %} {% csrf_token %}
<table class="table"> <table class="table">
{{ form }} <thead><tr><th>Personal settings</th></tr></thead>
<tr>
<th>{{ form.first_name.label_tag }}</th>
<td><ul class="errorlist">{{ form.first_name.errors }}</ul>{{ form.first_name }}</td>
</tr>
<tr>
<th>{{ form.last_name.label_tag }}</th>
<td><ul class="errorlist">{{ form.last_name.errors }}</ul>{{ form.last_name }}</td>
</tr>
<tr>
<th>{{ form.email.label_tag }}</th>
<td><ul class="errorlist">{{ form.email.errors }}</ul>{{ form.email }}</td>
</tr>
</table>
<table class="table">
<thead><tr><th>Feed settings</th></tr></thead>
<tr>
<th>{{ form.feed_upstream_info.label_tag }}</th>
<td><ul class="errorlist">{{ form.feed_upstream_info.errors }}</ul>{{ form.feed_upstream_info }}</td>
</tr>
<tr>
<th>{{ form.feed_portage_info.label_tag }}</th>
<td><ul class="errorlist">{{ form.feed_portage_info.errors }}</ul>{{ form.feed_portage_info }}</td>
</tr>
<tr>
<th>{{ form.feed_show_adds.label_tag }}</th>
<td><ul class="errorlist">{{ form.feed_show_adds.errors }}</ul>{{ form.feed_show_adds }}</td>
</tr>
<tr>
<th>{{ form.feed_show_removals.label_tag }}</th>
<td><ul class="errorlist">{{ form.feed_show_removals.errors }}</ul>{{ form.feed_show_removals }}</td>
</tr>
<tr>
<th>{{ form.feed_ignore_pre.label_tag }}</th>
<td><ul class="errorlist">{{ form.feed_ignore_pre.errors }}</ul>{{ form.feed_ignore_pre }}</td>
</tr>
<tr>
<th>{{ form.feed_ignore_pre_if_stable.label_tag }}</th>
<td><ul class="errorlist">{{ form.feed_ignore_pre_if_stable.errors }}</ul>{{ form.feed_ignore_pre_if_stable }}</td>
</tr>
</table>
<table class="table">
<thead><tr><th>Mail settings</th></tr></thead>
<tr>
<th>{{ form.email_activated.label_tag }}</th>
<td><ul class="errorlist">{{ form.email_activated.errors }}</ul>{{ form.email_activated }}</td>
</tr>
<tr>
<th>{{ form.email_ignore_pre.label_tag }}</th>
<td><ul class="errorlist">{{ form.email_ignore_pre.errors }}</ul>{{ form.email_ignore_pre }}</td>
</tr>
<tr>
<th>{{ form.email_ignore_pre_if_stable.label_tag }}</th>
<td><ul class="errorlist">{{ form.email_ignore_pre_if_stable.errors }}</ul>{{ form.email_ignore_pre_if_stable }}</td>
</tr>
<tr><td>&nbsp;</td><td></td></tr>
<tr> <tr>
<td></td> <td></td>
<td> <td>
<input class="btn" type='submit' value="Save" /> <input class="btn btn-large" type='submit' value="Save" />
</td> </td>
</tr> </tr>
</table> </table>

View File

@ -430,7 +430,7 @@ def accounts_index(request):
@render_to('euscan/accounts/preferences.html') @render_to('euscan/accounts/preferences.html')
def accounts_preferences(request): def accounts_preferences(request):
user = request.user user = request.user
profile = get_profile(user) prof = get_profile(user)
updated = False updated = False
if request.method == "POST": if request.method == "POST":
@ -441,10 +441,10 @@ def accounts_preferences(request):
user.email = form.cleaned_data["email"] user.email = form.cleaned_data["email"]
user.save(force_update=True) user.save(force_update=True)
profile.upstream_info = form.cleaned_data["upstream_info"] prof.feed_upstream_info = form.cleaned_data["feed_upstream_info"]
profile.portage_info = form.cleaned_data["portage_info"] prof.feed_portage_info = form.cleaned_data["feed_portage_info"]
profile.save(force_update=True) prof.save(force_update=True)
updated = True updated = True
else: else:
@ -452,8 +452,15 @@ def accounts_preferences(request):
"first_name": user.first_name, "first_name": user.first_name,
"last_name": user.last_name, "last_name": user.last_name,
"email": user.email, "email": user.email,
"upstream_info": profile.upstream_info, "feed_upstream_info": prof.feed_upstream_info,
"portage_info": profile.portage_info, "feed_portage_info": prof.feed_portage_info,
"feed_show_adds": prof.feed_show_adds,
"feed_show_removals": prof.feed_show_removals,
"feed_ignore_pre": prof.feed_ignore_pre,
"feed_ignore_pre_if_stable": prof.feed_ignore_pre_if_stable,
"email_activated": prof.email_activated,
"email_ignore_pre": prof.email_ignore_pre,
"email_ignore_pre_if_stable": prof.email_ignore_pre_if_stable,
} }
form = PreferencesForm(initial_data) form = PreferencesForm(initial_data)
return {"form": form, "updated": updated} return {"form": form, "updated": updated}

View File

@ -1,8 +1,11 @@
import re import re
gentoo_unstable = ("alpha", "beta", "pre", "rc")
gentoo_types = ("alpha", "beta", "pre", "rc", "p")
def is_version_type_stable(version_type): def is_version_type_stable(version_type):
return version_type not in ("alpha", "beta", "pre", "rc") return version_type not in gentoo_unstable
def is_version_stable(version): def is_version_stable(version):
@ -11,7 +14,6 @@ def is_version_stable(version):
def get_version_type(version): def get_version_type(version):
types = [] types = []
gentoo_types = ("alpha", "beta", "pre", "rc", "p")
for token in re.findall("[\._-]([a-zA-Z]+)", version): for token in re.findall("[\._-]([a-zA-Z]+)", version):
if token in gentoo_types: if token in gentoo_types: