]> git.openstreetmap.org Git - osqa.git/blob - forum_modules/updater/views.py
creating some views for the update checker and creating the functions that get the...
[osqa.git] / forum_modules / updater / views.py
1 import sys
2
3 from django import VERSION as DJANGO_VERSION
4 from django.http import HttpResponse
5 from django.utils.translation import ugettext as _
6 from django.utils import simplejson
7
8 from base import get_site_views, get_server_name
9 from settings import SITE_KEY
10 from forum.settings import APP_URL, SVN_REVISION
11 from forum.views.admin import admin_tools_page, admin_page
12
13 @admin_tools_page(_('updater'), _('Update Checker'))
14 def updater_index(request):
15     return (
16         'modules/updater/index.html',
17         {
18
19         },
20     )
21
22 def updater_check(request):
23     # Get the SVN Revision
24     try:
25         svn_revision = int(SVN_REVISION.replace('SVN-', ''))
26     except ValueError:
27         # Here we'll have to find another way of getting the SVN revision
28         svn_revision = 0
29
30     statistics = """<check>
31     <key value="%(site_key)s" />
32     <app_url value="%(app_url)s" />
33     <svn_revision value="%(svn_revision)d" />
34     <views value="%(site_views)d" />
35     <active_users value="11959" />
36     <server value="%(server_name)s" />
37     <python_version value="%(python_version)s" />
38     <django_version value="%(django_version)s" />
39     <database value="MySQL 5" />
40     <os value="Linux" />
41 </check> """ % {
42         'site_key' : SITE_KEY,
43         'app_url' : APP_URL,
44         'svn_revision' : svn_revision,
45         'site_views' : get_site_views(),
46         'server_name' : get_server_name(),
47         'python_version' : ''.join(sys.version.splitlines()),
48         'django_version' : str(DJANGO_VERSION),
49     }
50     return HttpResponse(statistics, mimetype='text/plain')
51
52
53     json = simplejson.dumps({'name' : 'Jordan'})
54     return HttpResponse(json, mimetype='application/json')