Commits

php  committed 9be94f3

downloads: fix import and paths

  • Participants
  • Parent commits bef0933

Comments (0)

Files changed (2)

File hgscm/apps/www/models.py

 from django.db import models
 from django.utils import simplejson
+from django.conf import settings
+import os
 
 def get_download(platform, version):
     '''get the download for the right version'''
-    f = open('downloads.json')
+    f = open(os.path.join(settings.MEDIA_ROOT, "downloads.json"))
     list = simplejson.load(f)
     f.close()
     latest = version == 'latest' or not version
                     return version['url']
 def get_latest_version():
     '''return the latest available version'''
-    f = open('downloads.json')
+    f = open(os.path.join(settings.MEDIA_ROOT, "downloads.json"))
     list = simplejson.load(f)
     f.close()
     for entry in list:

File hgscm/apps/www/views.py

 from django.template import RequestContext
 from django.http import HttpResponseRedirect
 from django.utils import simplejson
-from apps.www.models import get_download, get_latest_version
+from django.conf import settings
+from hgscm.apps.www.models import get_download, get_latest_version
+import os
 
 def frontpage(request):
     return render_to_response("frontpage.html", { 'latest_version': get_latest_version() },
 def download(request, platform, version):
     return HttpResponseRedirect(get_download(platform, version))
 def downloads(request):
-    f = open("downloads.json")
+    f = open(os.path.join(settings.MEDIA_ROOT, "downloads.json"))
     list = simplejson.load(f)
     f.close()
     return render_to_response("downloads.html", {'downloads': list},