From c85de09947b749304437ed09fbf0750dfb0d5194 Mon Sep 17 00:00:00 2001 From: volpino Date: Sun, 13 May 2012 14:09:22 +0200 Subject: [PATCH] some more cleaning, removing relative imports --- euscanwww/djeuscan/admin.py | 4 ++-- euscanwww/djeuscan/charts.py | 10 ++++----- euscanwww/djeuscan/models.py | 24 ++++++++++----------- euscanwww/djeuscan/templatetags/packages.py | 4 ++-- euscanwww/djeuscan/urls.py | 4 ++-- euscanwww/djeuscan/views.py | 3 +-- 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/euscanwww/djeuscan/admin.py b/euscanwww/djeuscan/admin.py index 563cd2c..45bdbeb 100644 --- a/euscanwww/djeuscan/admin.py +++ b/euscanwww/djeuscan/admin.py @@ -1,5 +1,5 @@ -from models import Package, Version, VersionLog, EuscanResult, Log, WorldLog, \ - CategoryLog, HerdLog, MaintainerLog, Herd, Maintainer +from djeuscan.models import Package, Version, VersionLog, EuscanResult, \ + Log, WorldLog, CategoryLog, HerdLog, MaintainerLog, Herd, Maintainer from django.contrib import admin admin.site.register(Herd) diff --git a/euscanwww/djeuscan/charts.py b/euscanwww/djeuscan/charts.py index 90ec4c8..4e4ca97 100644 --- a/euscanwww/djeuscan/charts.py +++ b/euscanwww/djeuscan/charts.py @@ -64,16 +64,16 @@ def chart_name(name, **kwargs): def getpackages(**kwargs): - packages = Package.objects + pkgs = Package.objects if 'category' in kwargs and kwargs['category']: - packages = Package.objects.for_category(kwargs['category']) + pkgs = Package.objects.for_category(kwargs['category']) if 'herd' in kwargs and kwargs['herd']: - packages = Package.objects.for_herd(kwargs['herd']) + pkgs = Package.objects.for_herd(kwargs['herd']) if 'maintainer' in kwargs and kwargs['maintainer']: - packages = Package.objects.for_maintainer(kwargs['maintainer']) + pkgs = Package.objects.for_maintainer(kwargs['maintainer']) - return packages + return pkgs def cached_pylab_chart(f): diff --git a/euscanwww/djeuscan/models.py b/euscanwww/djeuscan/models.py index 05b1663..45a618b 100644 --- a/euscanwww/djeuscan/models.py +++ b/euscanwww/djeuscan/models.py @@ -62,15 +62,15 @@ class Package(models.Model): objects = PackageManager() - @property - def homepages(self): - return self.homepage.split(' ') + class Meta: + unique_together = ['category', 'name'] def __unicode__(self): return '%s/%s' % (self.category, self.name) - class Meta: - unique_together = ['category', 'name'] + @property + def homepages(self): + return self.homepage.split(' ') class Version(models.Model): @@ -87,15 +87,15 @@ class Version(models.Model): urls = models.TextField(blank=True) alive = models.BooleanField(default=True, db_index=True) + class Meta: + unique_together = ['package', 'slot', 'revision', 'version', 'overlay'] + def __unicode__(self): return '%s/%s-%s-%s:%s [%s]' % ( self.package.category, self.package.name, self.version, self.revision, self.slot, self.overlay ) - class Meta: - unique_together = ['package', 'slot', 'revision', 'version', 'overlay'] - class VersionLog(models.Model): VERSION_ADDED = 1 @@ -116,10 +116,6 @@ class VersionLog(models.Model): objects = VersionLogManager() - def tag(self): - return '%s-%s:%s-[%s]' % (self.version, self.revision, self.slot, - self.overlay) - def __unicode__(self): txt = '+ ' if self.action == self.VERSION_ADDED else '- ' txt += '%s/%s-%s-%s:%s [%s]' % ( @@ -129,6 +125,10 @@ class VersionLog(models.Model): ) return txt + def tag(self): + return '%s-%s:%s-[%s]' % (self.version, self.revision, self.slot, + self.overlay) + class EuscanResult(models.Model): package = models.ForeignKey(Package) diff --git a/euscanwww/djeuscan/templatetags/packages.py b/euscanwww/djeuscan/templatetags/packages.py index 370e4a5..91e8af3 100644 --- a/euscanwww/djeuscan/templatetags/packages.py +++ b/euscanwww/djeuscan/templatetags/packages.py @@ -4,8 +4,8 @@ register = template.Library() @register.inclusion_tag('euscan/_packages.html', takes_context=True) -def packages(context, packages): - context['packages'] = packages +def packages(context, pkgs): + context['packages'] = pkgs return context diff --git a/euscanwww/djeuscan/urls.py b/euscanwww/djeuscan/urls.py index 1715c69..019f99a 100644 --- a/euscanwww/djeuscan/urls.py +++ b/euscanwww/djeuscan/urls.py @@ -1,6 +1,6 @@ from django.conf.urls.defaults import url, patterns, include -from feeds import PackageFeed, CategoryFeed, HerdFeed, MaintainerFeed, \ - GlobalFeed +from djeuscan.feeds import PackageFeed, CategoryFeed, HerdFeed, \ + MaintainerFeed, GlobalFeed package_patterns = patterns('djeuscan.views', url(r'^(?P[\w+][\w+.-]*)/(?P[\w+][\w+.-]*)/feed/$', diff --git a/euscanwww/djeuscan/views.py b/euscanwww/djeuscan/views.py index c11731f..56015b9 100644 --- a/euscanwww/djeuscan/views.py +++ b/euscanwww/djeuscan/views.py @@ -8,8 +8,7 @@ from djeuscan.helpers import version_key, packages_from_names from djeuscan.models import Version, Package, Herd, Maintainer, EuscanResult, \ VersionLog from djeuscan.forms import WorldForm, PackagesForm - -import charts +from djeuscan import charts @render_to('euscan/index.html')