euscanwww: Use Version.tag to be more DRY

Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
volpino 2012-11-08 15:19:45 +01:00
parent b838f3cb59
commit effab2015b
4 changed files with 22 additions and 8 deletions

View File

@ -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):

View File

@ -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

View File

@ -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)

View File

@ -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 %}