Mercurial > public > sg101
changeset 760:630ecac7665f
Removed the phantombrigade application.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 11 Jan 2014 16:11:50 -0600 |
parents | 2caab5249a71 |
children | 1ddd72f48d73 |
files | phantombrigade/__init__.py phantombrigade/models.py phantombrigade/urls.py phantombrigade/views.py sg101/settings/base.py sg101/urls.py |
diffstat | 5 files changed, 0 insertions(+), 122 deletions(-) [+] |
line wrap: on
line diff
--- a/phantombrigade/models.py Sat Jan 11 16:10:42 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -from django.db import models - -# Create your models here.
--- a/phantombrigade/urls.py Sat Jan 11 16:10:42 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -""" -Url patterns for the phantombrigade application. - -""" -from django.conf.urls import patterns, url - - -urlpatterns = patterns('phantombrigade.views', - url(r'^ts3/$', 'ts3_query', name='phantombrigade-ts3'), -)
--- a/phantombrigade/views.py Sat Jan 11 16:10:42 2014 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,102 +0,0 @@ -""" -Views for the phantombrigade application. - -The phantombrigade application doesn't have anything to do with SG101. It is -simply some useful web services that we provide to the gaming clan Phantom -Brigade. Rather than create a whole new website we just use the infrastructure -of SG101. - -Current we provide a TeamSpeak 3 status view for the PhantomBrigade.us website. - -""" -import json - -from django.conf import settings -from django.core.cache import cache -from django.http import HttpResponse, HttpResponseServerError -import ts3 - - -CACHE_KEY = 'phantombrigade-ts3-json' -CACHE_TIMEOUT = 2 * 60 - - -def ts3_query(request): - """ - Query the TeamSpeak3 server for status, and output a JSON representation. - - The JSON we return is targeted towards the jQuery plugin Dynatree - http://code.google.com/p/dynatree/ - - """ - # Do we have the result cached? - result = cache.get(CACHE_KEY) - if result: - return HttpResponse(result, content_type='application/json') - - # Cache miss, go query the remote server - - try: - svr = ts3.TS3Server(settings.PB_TS3_IP, settings.PB_TS3_PORT, - settings.PB_TS3_VID) - except ts3.ConnectionError: - return HttpResponseServerError() - - response = svr.send_command('serverinfo') - if response.response.get('msg') != 'ok': - return HttpResponseServerError() - svr_info = response.data[0] - - response = svr.send_command('channellist') - if response.response.get('msg') != 'ok': - return HttpResponseServerError() - channel_list = response.data - - response = svr.send_command('clientlist') - if response.response.get('msg') != 'ok': - return HttpResponseServerError() - client_list = response.data - - # Start building the channel / client tree. - # We save tree nodes in a dictionary, keyed by their id so we can find them - # later in order to support arbitrary channel hierarchies. - channels = {} - - # Build the root, or channel 0 - channels[0] = { - 'title': svr_info['virtualserver_name'], - 'isFolder': True, - 'expand': True, - 'children': [] - } - - # Add the channels to our tree - - for channel in channel_list: - node = { - 'title': channel['channel_name'], - 'isFolder': True, - 'expand': True, - 'children': [] - } - parent = channels[int(channel['pid'])] - parent['children'].append(node) - channels[int(channel['cid'])] = node - - # Add the clients to the tree - - for client in client_list: - if client['client_type'] == '0': - node = { - 'title': client['client_nickname'], - 'icon': 'client.png' - } - channel = channels[int(client['cid'])] - channel['children'].append(node) - - tree = [channels[0]] - status = json.dumps(tree) - - cache.set(CACHE_KEY, status, CACHE_TIMEOUT) - - return HttpResponse(status, content_type='application/json')
--- a/sg101/settings/base.py Sat Jan 11 16:10:42 2014 -0600 +++ b/sg101/settings/base.py Sat Jan 11 16:11:50 2014 -0600 @@ -133,7 +133,6 @@ 'messages', 'news', 'oembed', - 'phantombrigade', 'podcast', 'polls', 'potd', @@ -278,11 +277,6 @@ GOOGLE_OAUTH_CONSUMER_KEY = 'surfguitar101.com' GOOGLE_OAUTH_PRIVATE_KEY_PATH = SECRETS['GOOGLE_KEY_PATH'] -# Phantom Brigade TeamSpeak3 settings -PB_TS3_IP = '208.77.144.55' -PB_TS3_PORT = 10011 -PB_TS3_VID = 17 - # MoinMoin Wiki integration settings WIKI_COOKIE_NAME = 'sg101_wiki' WIKI_COOKIE_DOMAIN = '.surfguitar101.com'
--- a/sg101/urls.py Sat Jan 11 16:10:42 2014 -0600 +++ b/sg101/urls.py Sat Jan 11 16:11:50 2014 -0600 @@ -77,7 +77,6 @@ (r'^messages/', include('messages.urls')), (r'^news/', include('news.urls')), (r'^oembed/', include('oembed.urls')), - (r'^pb/', include('phantombrigade.urls')), (r'^podcast/', include('podcast.urls')), (r'^polls/', include('polls.urls')), (r'^potd/', include('potd.urls')),