diff options
author | volpino <fox91@anche.no> | 2012-09-22 16:08:38 +0200 |
---|---|---|
committer | Corentin Chary <corentin.chary@gmail.com> | 2012-10-29 13:06:04 +0100 |
commit | c519f6b28a4becb227b74556cbbaed99bcef0553 (patch) | |
tree | 0daeb8dad38b7b7b1fcc1f901b2a3b2b4c6b65ef | |
parent | euscanwww: Wrapping herds and maintainers in <p> to put them in newlines (diff) | |
download | euscan-c519f6b28a4becb227b74556cbbaed99bcef0553.tar.gz euscan-c519f6b28a4becb227b74556cbbaed99bcef0553.tar.bz2 euscan-c519f6b28a4becb227b74556cbbaed99bcef0553.zip |
euscan: last_version property added
Signed-off-by: volpino <fox91@anche.no>
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | euscanwww/djeuscan/models.py | 14 |
2 files changed, 14 insertions, 2 deletions
@@ -79,8 +79,6 @@ Move log models into djeuscanhistory ? - Url ad ManyToMany - Arches and Keyword - Metadata, herds, maintainers and homepage are per-version, not per package. Store it in Version instead. - Define last_version that refers to the last version (can be last_version_gentoo or last_version_overlay) - Fix update_counter, to update this field. ### djportage (LOW-PRIORITY)) diff --git a/euscanwww/djeuscan/models.py b/euscanwww/djeuscan/models.py index cb0e0e0..a328522 100644 --- a/euscanwww/djeuscan/models.py +++ b/euscanwww/djeuscan/models.py @@ -116,6 +116,20 @@ class Package(models.Model): def homepages(self): return self.homepage.split(' ') + @property + def last_version(self): + from euscan.helpers import vercmp + + versions = [ + self.last_version_gentoo, + self.last_version_overlay, + self.last_version_upstream + ] + _cmp = lambda x, y: vercmp( + unicode(self), x.version if x else "", y.version if y else "" + ) + return sorted(versions, cmp=_cmp)[-1] + class Version(models.Model): """ |