Mercurial > hg-website
view 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 |
line wrap: on
line source
from django.db import models from django.utils import simplejson def get_download(platform, version): '''get the download for the right version''' f = open('downloads.json') list = simplejson.load(f) f.close() latest = version == 'latest' or not version for entry in list: if (latest and entry['latest'] == 'true') or entry['version'] == version: for version in entry['versions']: if version['identifier'] == platform: return version['url'] def get_latest_version(): '''return the latest available version''' f = open('downloads.json') list = simplejson.load(f) f.close() for entry in list: if entry['latest'] == 'true': return entry['version']