Mercurial > hg-website
comparison hgscm/apps/www/models.py @ 71:9be94f3dcaa0
downloads: fix import and paths
author | David Soria Parra <dsp@php.net> |
---|---|
date | Wed, 18 Feb 2009 15:46:23 +0100 |
parents | bef09338eceb |
children | 8d25e34c21c2 |
comparison
equal
deleted
inserted
replaced
70:bef09338eceb | 71:9be94f3dcaa0 |
---|---|
1 from django.db import models | 1 from django.db import models |
2 from django.utils import simplejson | 2 from django.utils import simplejson |
3 from django.conf import settings | |
4 import os | |
3 | 5 |
4 def get_download(platform, version): | 6 def get_download(platform, version): |
5 '''get the download for the right version''' | 7 '''get the download for the right version''' |
6 f = open('downloads.json') | 8 f = open(os.path.join(settings.MEDIA_ROOT, "downloads.json")) |
7 list = simplejson.load(f) | 9 list = simplejson.load(f) |
8 f.close() | 10 f.close() |
9 latest = version == 'latest' or not version | 11 latest = version == 'latest' or not version |
10 for entry in list: | 12 for entry in list: |
11 if (latest and entry['latest'] == 'true') or entry['version'] == version: | 13 if (latest and entry['latest'] == 'true') or entry['version'] == version: |
12 for version in entry['versions']: | 14 for version in entry['versions']: |
13 if version['identifier'] == platform: | 15 if version['identifier'] == platform: |
14 return version['url'] | 16 return version['url'] |
15 def get_latest_version(): | 17 def get_latest_version(): |
16 '''return the latest available version''' | 18 '''return the latest available version''' |
17 f = open('downloads.json') | 19 f = open(os.path.join(settings.MEDIA_ROOT, "downloads.json")) |
18 list = simplejson.load(f) | 20 list = simplejson.load(f) |
19 f.close() | 21 f.close() |
20 for entry in list: | 22 for entry in list: |
21 if entry['latest'] == 'true': | 23 if entry['latest'] == 'true': |
22 return entry['version'] | 24 return entry['version'] |