diff options
author | volpino <fox91@anche.no> | 2012-11-08 15:19:45 +0100 |
---|---|---|
committer | volpino <fox91@anche.no> | 2012-11-08 15:19:45 +0100 |
commit | effab2015bee9e6fb6960ee696fc651f8e13525c (patch) | |
tree | b94c4e1e7927a1360e5060518bc82afb18cc8874 /euscanwww | |
parent | Merge branch 'master' of https://github.com/iksaif/euscan (diff) | |
download | euscan-effab2015bee9e6fb6960ee696fc651f8e13525c.tar.gz euscan-effab2015bee9e6fb6960ee696fc651f8e13525c.tar.bz2 euscan-effab2015bee9e6fb6960ee696fc651f8e13525c.zip |
euscanwww: Use Version.tag to be more DRY
Signed-off-by: volpino <fox91@anche.no>
Diffstat (limited to 'euscanwww')
-rw-r--r-- | euscanwww/djeuscan/feeds.py | 5 | ||||
-rw-r--r-- | euscanwww/djeuscan/helpers.py | 9 | ||||
-rw-r--r-- | euscanwww/djeuscan/models.py | 14 | ||||
-rw-r--r-- | euscanwww/djeuscan/templates/euscan/_package_details.html | 2 |
4 files changed, 22 insertions, 8 deletions
diff --git a/euscanwww/djeuscan/feeds.py b/euscanwww/djeuscan/feeds.py index 59b8e05..d34381e 100644 --- a/euscanwww/djeuscan/feeds.py +++ b/euscanwww/djeuscan/feeds.py @@ -44,9 +44,8 @@ class BaseFeed(Feed): def item_link(self, vlog): kwargs = {'category': vlog.package.category, 'package': vlog.package.name} - return "%s#version-%s-%s:%s-%s" % ( - reverse('djeuscan.views.package', kwargs=kwargs), - vlog.version, vlog.revision, vlog.slot, vlog.overlay, + return "%s#version-%s" % ( + reverse('djeuscan.views.package', kwargs=kwargs), vlog.tag ) def item_pubdate(self, vlog): diff --git a/euscanwww/djeuscan/helpers.py b/euscanwww/djeuscan/helpers.py index 171ba5e..6e8b4a0 100644 --- a/euscanwww/djeuscan/helpers.py +++ b/euscanwww/djeuscan/helpers.py @@ -98,3 +98,12 @@ def get_layman_repos(): lay = Layman(config=settings.LAYMAN_CONFIG) installed_overlays = lay.get_installed() return lay.get_all_info(installed_overlays) + + +def versiontag_to_attrs(tag): + import re + match = re.match(r"(.+)-(.+):(\d+)-(.+)", tag) + if match: + return match.groups() + else: + None diff --git a/euscanwww/djeuscan/models.py b/euscanwww/djeuscan/models.py index a09c3e3..04acceb 100644 --- a/euscanwww/djeuscan/models.py +++ b/euscanwww/djeuscan/models.py @@ -156,6 +156,11 @@ class Version(models.Model): class Meta: unique_together = ['package', 'slot', 'revision', 'version', 'overlay'] + @property + def tag(self): + return '%s-%s:%s-%s' % (self.version, self.revision, self.slot, + self.overlay) + def cpv(self): return '%s/%s-%s%s' % ( self.package.category, self.package.name, self.version, @@ -196,6 +201,11 @@ class VersionLog(models.Model): objects = VersionLogManager() + @property + 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]' % ( @@ -209,10 +219,6 @@ class VersionLog(models.Model): self.full_clean() super(VersionLog, self).save(*args, **kwargs) - 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/templates/euscan/_package_details.html b/euscanwww/djeuscan/templates/euscan/_package_details.html index 7f92133..79efa9d 100644 --- a/euscanwww/djeuscan/templates/euscan/_package_details.html +++ b/euscanwww/djeuscan/templates/euscan/_package_details.html @@ -73,7 +73,7 @@ <dd> <ul> {% for version in upstream %} - <li id="version-{{ version.version }}-{{version.revision }}:{{ version.slot }}-{{ version.overlay }}"> + <li id="version-{{ version.tag }}"> <img src="{{ STATIC_URL }}img/upstream-icon.png" alt="upstream" title="Upstream" /> {% if version.vtype and not version.vtype|is_stable %} |