Mercurial > public > sg101
comparison phantombrigade/views.py @ 679:89b240fe9297
For Django 1.5.2: import json; django.utils.simplejson is deprecated.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Thu, 15 Aug 2013 20:14:33 -0500 |
parents | 10f3acc18b2d |
children |
comparison
equal
deleted
inserted
replaced
678:38a198ea8c61 | 679:89b240fe9297 |
---|---|
7 of SG101. | 7 of SG101. |
8 | 8 |
9 Current we provide a TeamSpeak 3 status view for the PhantomBrigade.us website. | 9 Current we provide a TeamSpeak 3 status view for the PhantomBrigade.us website. |
10 | 10 |
11 """ | 11 """ |
12 import json | |
13 | |
12 from django.conf import settings | 14 from django.conf import settings |
13 from django.core.cache import cache | 15 from django.core.cache import cache |
14 from django.http import HttpResponse, HttpResponseServerError | 16 from django.http import HttpResponse, HttpResponseServerError |
15 from django.utils import simplejson | |
16 import ts3 | 17 import ts3 |
17 | 18 |
18 | 19 |
19 CACHE_KEY = 'phantombrigade-ts3-json' | 20 CACHE_KEY = 'phantombrigade-ts3-json' |
20 CACHE_TIMEOUT = 2 * 60 | 21 CACHE_TIMEOUT = 2 * 60 |
92 } | 93 } |
93 channel = channels[int(client['cid'])] | 94 channel = channels[int(client['cid'])] |
94 channel['children'].append(node) | 95 channel['children'].append(node) |
95 | 96 |
96 tree = [channels[0]] | 97 tree = [channels[0]] |
97 json = simplejson.dumps(tree) | 98 status = json.dumps(tree) |
98 | 99 |
99 cache.set(CACHE_KEY, json, CACHE_TIMEOUT) | 100 cache.set(CACHE_KEY, status, CACHE_TIMEOUT) |
100 | 101 |
101 return HttpResponse(json, content_type='application/json') | 102 return HttpResponse(status, content_type='application/json') |