Mercurial > hg-website
comparison hgscm/apps/www/models.py @ 70:bef09338eceb
downloads: add initial handling for downloads
We are using json as a format to store our download information
as the format is rather simple and can be parsed without problems
and dependencies.
author | David Soria Parra <dsp@php.net> |
---|---|
date | Wed, 18 Feb 2009 15:32:57 +0100 |
parents | b3d9cbb33d54 |
children | 9be94f3dcaa0 |
comparison
equal
deleted
inserted
replaced
69:a7dceecdbd46 | 70:bef09338eceb |
---|---|
1 from django.db import models | 1 from django.db import models |
2 from django.utils import simplejson | |
2 | 3 |
3 # Create your models here. | 4 def get_download(platform, version): |
5 '''get the download for the right version''' | |
6 f = open('downloads.json') | |
7 list = simplejson.load(f) | |
8 f.close() | |
9 latest = version == 'latest' or not version | |
10 for entry in list: | |
11 if (latest and entry['latest'] == 'true') or entry['version'] == version: | |
12 for version in entry['versions']: | |
13 if version['identifier'] == platform: | |
14 return version['url'] | |
15 def get_latest_version(): | |
16 '''return the latest available version''' | |
17 f = open('downloads.json') | |
18 list = simplejson.load(f) | |
19 f.close() | |
20 for entry in list: | |
21 if entry['latest'] == 'true': | |
22 return entry['version'] |