cablegates/pandora/app/views.py

47 lines
1.7 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404
from django.template import RequestContext
2009-10-04 23:48:18 +00:00
from django.conf import settings
2010-02-10 13:10:14 +00:00
from oxdjango.shortcuts import json_response, render_to_json_response, get_object_or_404_json
import models
2010-08-24 17:16:33 +00:00
def intro(request):
context = RequestContext(request, {'settings':settings})
return render_to_response('intro.html', context)
def index(request):
2010-02-08 10:26:25 +00:00
context = RequestContext(request, {'settings':settings})
return render_to_response('index.html', context)
def timeline(request):
context = RequestContext(request, {'settings':settings})
return render_to_response('timeline.html', context)
2010-02-10 13:10:14 +00:00
def api_getPage(request):
data = json.loads(request.POST['data'])
name = data['page']
page = get_object_or_404_json(models.Archive, name=name)
response = json_response({'name': page.name, 'body': page.body})
return render_to_json_response(response)
return render_to_response('site.js', context, mimetype="application/javascript")
2010-02-08 10:26:25 +00:00
def site_js(request):
2010-02-10 13:10:14 +00:00
pages = models.Page.objects.all()
2010-02-27 11:44:38 +00:00
siteSettings = {}
for s in models.SiteSettings.objects.all():
siteSettings[s.key] = s.value
context = RequestContext(request, {'settings':settings, 'pages': pages, 'siteSettings': siteSettings})
2010-02-08 10:26:25 +00:00
return render_to_response('site.js', context, mimetype="application/javascript")
2010-09-07 13:08:23 +00:00
def pandora_json(request):
siteSettings = {}
for s in models.SiteSettings.objects.all():
siteSettings[s.key] = s.value
context = RequestContext(request, {'settings':settings, 'siteSettings': siteSettings})
return render_to_response('pandora.json', context, mimetype="application/javascript")