event/views.py
author nishanth
Mon, 19 Apr 2010 23:01:24 +0530
changeset 6 8929b82c1dbb
parent 4 e3b8a3ae3857
child 7 dfedb369f32e
permissions -rw-r--r--
added home page with minimum functionality
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
     1
from django.http import Http404
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
     2
from django.shortcuts import render_to_response
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
     3
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
     4
from offline.event.models import Event
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
     5
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
     6
def event_home(request):
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
     7
    """ The page for people to view.
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
     8
    """
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
     9
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
    10
    try:
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
    11
        event = Event.objects.all()[0]
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
    12
    except IndexError:
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
    13
        raise Http404
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
    14
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
    15
    ip = request.META['REMOTE_ADDR']
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
    16
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
    17
    can_submit_feedback = True if event.feedback_status != '0' and \
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
    18
            not event.feedback.filter(day=event.feedback_status,user_ip=ip) else False
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
    19
    can_take_quiz = False
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
    20
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
    21
    return render_to_response('home.html', {'event':event, 'can_submit_feedback':can_submit_feedback, 'can_take_quiz':can_take_quiz})
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
    22