Skip to content
Snippets Groups Projects
Select Git revision
  • 43fdd9f1d752c9b8b06d2350982da25080baf920
  • test default protected
  • master protected
  • original
  • pirati-backup protected
  • beta-2
  • beta-1
  • v3.1.4
  • v3.1.3
  • v3.1.2
  • v3.1.1
  • v3.1.0
  • v3.0.16
  • v3.0.15
  • v3.0.14
  • v3.0.13
  • v3.0.12
  • v3.0.11
  • v3.0.10
  • v3.0.9
  • v3.0.8
  • v3.0.7
  • v3.0.6
  • v3.0.5
  • v3.0.4
25 results

view_utils.py

Blame
  • view_utils.py 820 B
    """
    Utilities for single election views
    
    Ben Adida (2009-07-18)
    """
    
    from django.template import Context, Template, loader
    from django.http import HttpResponse, Http404
    from django.shortcuts import render_to_response
    
    from auth.security import get_user
    
    from django.conf import settings
    
    ##
    ## template abstraction
    ##
    def render_template(request, template_name, vars = {}):
      t = loader.get_template(template_name + '.html')
      
      vars_with_user = vars.copy()
      vars_with_user['user'] = get_user(request)
      vars_with_user['settings'] = settings
      vars_with_user['CURRENT_URL'] = request.path
      
      # csrf protection
      if request.session.has_key('csrf_token'):
        vars_with_user['csrf_token'] = request.session['csrf_token']
      
      return render_to_response('server_ui/templates/%s.html' % template_name, vars_with_user)