# -*- coding: utf-8 -*-

from django.shortcuts import render_to_response
from Instanssi.kompomaatti.models import Compo, VoteCode
from django.template import RequestContext
from Instanssi.dbsettings.models import Setting

def custom_render(request, tpl, context={}):
    active_event_id = Setting.get('active_event_id', 'events', -1)
    context['compos'] = Compo.objects.filter(active=True, event=active_event_id)
    context['logged'] = request.user.is_authenticated()
    context['is_su'] = request.user.is_superuser
    associated = False
    votecode = None
    try:
        votecode = VoteCode.objects.get(associated_to=request.user)
        associated = True
    except:
        pass
    context['associated'] = associated
    context['votecode'] = votecode
    return render_to_response(tpl, context, context_instance=RequestContext(request))
@@ -75,102 +75,92 @@
 rom 
-Instanssi.kompomaatti.models import Compo, VoteCode%0Afrom django.template import RequestContext
+django.template import RequestContext%0Afrom django.shortcuts import get_object_or_404
 %0Afro
@@ -175,18 +175,19 @@
 ssi.
-dbsettings
+kompomaatti
 .mod
@@ -197,23 +197,21 @@
  import 
-Setting
+Event
 %0A%0Adef cu
@@ -257,501 +257,219 @@
     
-active_event_id = Setting.get('active_event_id', 'events', -1)%0A    context%5B'compos'%5D = Compo.objects.filter(active=True, event=active_event_id)%0A    context%5B'logged'%5D = request.user.is_authenticated()%0A    context%5B'is_su'%5D = request.user.is_superuser%0A    associated = False%0A    votecode = None%0A    try:%0A        votecode = VoteCode.objects.get(associated_to=request.user)%0A        associated = True%0A    except:%0A        pass%0A    context%5B'associated'%5D = associated%0A    context%5B'votecode'%5D = votecode
+context%5B'user'%5D = request.user%0A    %0A    # Get event name%0A    if 'sel_event_id' in context:%0A        event = get_object_or_404(Event, pk=context%5B'sel_event_id'%5D)%0A        context%5B'sel_event_name'%5D = event.name%0A    
 %0A   

Change custom_render