summaryrefslogtreecommitdiffstats
path: root/releng
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-11-21 02:33:49 +0100
committerDan McGee <dan@archlinux.org>2012-11-21 02:33:49 +0100
commit402487b007e206b013ecbf8b3017dc1231f4bbbc (patch)
tree9f0887cffd45264880670601f5fa00a1eb5f1004 /releng
parentf7331a0eca351300685ebee494e810d8c82c35b1 (diff)
downloadarchweb-402487b007e206b013ecbf8b3017dc1231f4bbbc.tar.gz
archweb-402487b007e206b013ecbf8b3017dc1231f4bbbc.tar.xz
Move some logic out of the templates to the Release model
This includes magnet URI generation, ISO paths, etc. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'releng')
-rw-r--r--releng/models.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/releng/models.py b/releng/models.py
index 2f9a078..c591bc0 100644
--- a/releng/models.py
+++ b/releng/models.py
@@ -1,3 +1,5 @@
+from urllib import urlencode
+
from django.core.urlresolvers import reverse
from django.db import models
from django.db.models.signals import pre_save
@@ -121,6 +123,22 @@ class Release(models.Model):
def __unicode__(self):
return self.version
+ def dir_path(self):
+ return "iso/%s/" % self.version
+
+ def iso_url(self):
+ return "iso/%s/archlinux-%s-dual.iso" % (self.version, self.version)
+
+ def magnet_uri(self):
+ query = {
+ 'dn': "archlinux-%s-dual.iso" % self.version,
+ 'tr': ("udp://tracker.archlinux.org:6969",
+ "http://tracker.archlinux.org:6969/announce"),
+ }
+ if self.torrent_infohash:
+ query['xt'] = "urn:btih:%s" % self.torrent_infohash
+ return "magnet:?%s" % urlencode(query, doseq=True)
+
for model in (Iso, Test, Release):
pre_save.connect(set_created_field, sender=model,