Mercurial > hg-website
comparison original/hgscm/apps/www/models.py @ 244:4b97017259f9
Move the original site into a single folder to reduce clutter.
author | Steve Losh <steve@stevelosh.com> |
---|---|
date | Wed, 23 Sep 2009 20:05:13 -0400 |
parents | hgscm/apps/www/models.py@8d25e34c21c2 |
children |
comparison
equal
deleted
inserted
replaced
240:85a7a53db1a5 | 244:4b97017259f9 |
---|---|
1 from django.db import models | |
2 from django.utils import simplejson | |
3 from django.conf import settings | |
4 import os, re | |
5 | |
6 def get_download(platform, version): | |
7 '''get the download for the right version''' | |
8 f = open(os.path.join(settings.MEDIA_ROOT, "downloads.json")) | |
9 list = simplejson.load(f) | |
10 f.close() | |
11 latest = version == 'latest' or not version | |
12 for entry in list: | |
13 if (latest and entry['latest'] == 'true') or entry['version'] == version: | |
14 for version in entry['versions']: | |
15 if version['identifier'] == platform: | |
16 return version | |
17 def get_download_for_agent(agent, version): | |
18 '''get the download for the right version''' | |
19 f = open(os.path.join(settings.MEDIA_ROOT, "downloads.json")) | |
20 list = simplejson.load(f) | |
21 f.close() | |
22 latest = version == 'latest' or not version | |
23 for entry in list: | |
24 if (latest and entry['latest'] == 'true') or entry['version'] == version: | |
25 for version in entry['versions']: | |
26 if re.search(version['system'], agent): | |
27 return version | |
28 | |
29 def get_latest_version(): | |
30 '''return the latest available version''' | |
31 f = open(os.path.join(settings.MEDIA_ROOT, "downloads.json")) | |
32 list = simplejson.load(f) | |
33 f.close() | |
34 for entry in list: | |
35 if entry['latest'] == 'true': | |
36 return entry['version'] |