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
  
  if 'election' in vars and get_user(request):
      try:
          vars_with_user['officer'] = ElectionOfficer.get_by_election_and_user(election=vars['election'], user=get_user(request))
      except:
          pass
  
  # 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)
def prepare_vars(request, vars):
  vars_with_user = vars.copy()
  vars_with_user['user'] = get_user(request)
  
  # csrf protection
  if request.session.has_key('csrf_token'):
    vars_with_user['csrf_token'] = request.session['csrf_token']
    
  vars_with_user['utils'] = utils
  vars_with_user['settings'] = settings
  vars_with_user['HELIOS_STATIC'] = '/static/helios/helios'
  vars_with_user['TEMPLATE_BASE'] = helios.TEMPLATE_BASE
  vars_with_user['CURRENT_URL'] = request.path
  vars_with_user['SECURE_URL_HOST'] = settings.SECURE_URL_HOST
  
  if 'election' in vars and get_user(request):
      try:
          vars_with_user['officer'] = ElectionOfficer.get_by_election_and_user(election=vars['election'], user=get_user(request))
      except:
          pass
      
  return vars_with_user
Beispiel #3
0
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

    if 'election' in vars and get_user(request):
        try:
            vars_with_user[
                'officer'] = ElectionOfficer.get_by_election_and_user(
                    election=vars['election'], user=get_user(request))
        except:
            pass

    # 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)
Beispiel #4
0
def prepare_vars(request, vars):
    vars_with_user = vars.copy()
    vars_with_user['user'] = get_user(request)

    # csrf protection
    if request.session.has_key('csrf_token'):
        vars_with_user['csrf_token'] = request.session['csrf_token']

    vars_with_user['utils'] = utils
    vars_with_user['settings'] = settings
    vars_with_user['HELIOS_STATIC'] = '/static/helios/helios'
    vars_with_user['TEMPLATE_BASE'] = helios.TEMPLATE_BASE
    vars_with_user['CURRENT_URL'] = request.path
    vars_with_user['SECURE_URL_HOST'] = settings.SECURE_URL_HOST

    if 'election' in vars and get_user(request):
        try:
            vars_with_user[
                'officer'] = ElectionOfficer.get_by_election_and_user(
                    election=vars['election'], user=get_user(request))
        except:
            pass

    return vars_with_user