mirror of
https://github.com/fergalmoran/dss.git
synced 2026-01-04 16:04:35 +00:00
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
from django.shortcuts import render_to_response
|
|
from django.template.context import RequestContext
|
|
from htmlmin.decorators import not_minified_response
|
|
from dss import localsettings
|
|
from spa.forms import UserForm
|
|
from spa.models import UserProfile
|
|
|
|
__author__ = 'fergalm'
|
|
|
|
|
|
@not_minified_response
|
|
def get_template(request, template_name):
|
|
#Temporary hack here to create user profiles for zombie users
|
|
if request.user.is_authenticated() and request.user.get_profile() is None:
|
|
zm, created = UserProfile.objects.get_or_create(user=request.user)
|
|
zm.save()
|
|
print "Created user %s" % zm
|
|
|
|
return render_to_response(
|
|
'views/%s.html' % template_name,
|
|
context_instance=RequestContext(request))
|
|
|
|
|
|
@not_minified_response
|
|
def get_template_ex(request, template_name):
|
|
html = render_to_response(
|
|
'views/%s.html' % template_name,
|
|
context_instance=RequestContext(request, {'form': UserForm()}))
|
|
return html
|
|
|
|
|
|
def get_javascript(request, template_name):
|
|
localsettings.JS_SETTINGS.update({
|
|
'CURRENT_USER_ID': request.user.id or -1
|
|
})
|
|
return render_to_response(
|
|
'javascript/%s.js' % template_name,
|
|
localsettings.JS_SETTINGS,
|
|
context_instance=RequestContext(request),
|
|
mimetype="text/javascript")
|