aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvolpino <fox91@anche.no>2012-09-22 16:08:38 +0200
committerCorentin Chary <corentin.chary@gmail.com>2012-10-29 13:06:04 +0100
commitc519f6b28a4becb227b74556cbbaed99bcef0553 (patch)
tree0daeb8dad38b7b7b1fcc1f901b2a3b2b4c6b65ef
parenteuscanwww: Wrapping herds and maintainers in <p> to put them in newlines (diff)
downloadeuscan-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--TODO2
-rw-r--r--euscanwww/djeuscan/models.py14
2 files changed, 14 insertions, 2 deletions
diff --git a/TODO b/TODO
index 9fda0b9..a0e3a26 100644
--- a/TODO
+++ b/TODO
@@ -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):
"""