some more cleaning, removing relative imports

This commit is contained in:
volpino 2012-05-13 14:09:22 +02:00
parent b339efe012
commit c85de09947
6 changed files with 24 additions and 25 deletions

View File

@ -1,5 +1,5 @@
from models import Package, Version, VersionLog, EuscanResult, Log, WorldLog, \ from djeuscan.models import Package, Version, VersionLog, EuscanResult, \
CategoryLog, HerdLog, MaintainerLog, Herd, Maintainer Log, WorldLog, CategoryLog, HerdLog, MaintainerLog, Herd, Maintainer
from django.contrib import admin from django.contrib import admin
admin.site.register(Herd) admin.site.register(Herd)

View File

@ -64,16 +64,16 @@ def chart_name(name, **kwargs):
def getpackages(**kwargs): def getpackages(**kwargs):
packages = Package.objects pkgs = Package.objects
if 'category' in kwargs and kwargs['category']: 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']: 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']: 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): def cached_pylab_chart(f):

View File

@ -62,15 +62,15 @@ class Package(models.Model):
objects = PackageManager() objects = PackageManager()
@property class Meta:
def homepages(self): unique_together = ['category', 'name']
return self.homepage.split(' ')
def __unicode__(self): def __unicode__(self):
return '%s/%s' % (self.category, self.name) return '%s/%s' % (self.category, self.name)
class Meta: @property
unique_together = ['category', 'name'] def homepages(self):
return self.homepage.split(' ')
class Version(models.Model): class Version(models.Model):
@ -87,15 +87,15 @@ class Version(models.Model):
urls = models.TextField(blank=True) urls = models.TextField(blank=True)
alive = models.BooleanField(default=True, db_index=True) alive = models.BooleanField(default=True, db_index=True)
class Meta:
unique_together = ['package', 'slot', 'revision', 'version', 'overlay']
def __unicode__(self): def __unicode__(self):
return '%s/%s-%s-%s:%s [%s]' % ( return '%s/%s-%s-%s:%s [%s]' % (
self.package.category, self.package.name, self.version, self.package.category, self.package.name, self.version,
self.revision, self.slot, self.overlay self.revision, self.slot, self.overlay
) )
class Meta:
unique_together = ['package', 'slot', 'revision', 'version', 'overlay']
class VersionLog(models.Model): class VersionLog(models.Model):
VERSION_ADDED = 1 VERSION_ADDED = 1
@ -116,10 +116,6 @@ class VersionLog(models.Model):
objects = VersionLogManager() objects = VersionLogManager()
def tag(self):
return '%s-%s:%s-[%s]' % (self.version, self.revision, self.slot,
self.overlay)
def __unicode__(self): def __unicode__(self):
txt = '+ ' if self.action == self.VERSION_ADDED else '- ' txt = '+ ' if self.action == self.VERSION_ADDED else '- '
txt += '%s/%s-%s-%s:%s [%s]' % ( txt += '%s/%s-%s-%s:%s [%s]' % (
@ -129,6 +125,10 @@ class VersionLog(models.Model):
) )
return txt return txt
def tag(self):
return '%s-%s:%s-[%s]' % (self.version, self.revision, self.slot,
self.overlay)
class EuscanResult(models.Model): class EuscanResult(models.Model):
package = models.ForeignKey(Package) package = models.ForeignKey(Package)

View File

@ -4,8 +4,8 @@ register = template.Library()
@register.inclusion_tag('euscan/_packages.html', takes_context=True) @register.inclusion_tag('euscan/_packages.html', takes_context=True)
def packages(context, packages): def packages(context, pkgs):
context['packages'] = packages context['packages'] = pkgs
return context return context

View File

@ -1,6 +1,6 @@
from django.conf.urls.defaults import url, patterns, include from django.conf.urls.defaults import url, patterns, include
from feeds import PackageFeed, CategoryFeed, HerdFeed, MaintainerFeed, \ from djeuscan.feeds import PackageFeed, CategoryFeed, HerdFeed, \
GlobalFeed MaintainerFeed, GlobalFeed
package_patterns = patterns('djeuscan.views', package_patterns = patterns('djeuscan.views',
url(r'^(?P<category>[\w+][\w+.-]*)/(?P<package>[\w+][\w+.-]*)/feed/$', url(r'^(?P<category>[\w+][\w+.-]*)/(?P<package>[\w+][\w+.-]*)/feed/$',

View File

@ -8,8 +8,7 @@ from djeuscan.helpers import version_key, packages_from_names
from djeuscan.models import Version, Package, Herd, Maintainer, EuscanResult, \ from djeuscan.models import Version, Package, Herd, Maintainer, EuscanResult, \
VersionLog VersionLog
from djeuscan.forms import WorldForm, PackagesForm from djeuscan.forms import WorldForm, PackagesForm
from djeuscan import charts
import charts
@render_to('euscan/index.html') @render_to('euscan/index.html')