event/views.py
author nishanth
Tue, 20 Apr 2010 01:31:45 +0530
changeset 7 dfedb369f32e
parent 6 8929b82c1dbb
child 9 601057af86c2
permissions -rw-r--r--
first fixed on the urls and then gave the admin_key in settings and then created main admin page.
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
7
dfedb369f32e first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents: 6
diff changeset
     6
from offline.settings import ADMIN_KEY
dfedb369f32e first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents: 6
diff changeset
     7
6
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
     8
def event_home(request):
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
     9
    """ The page for people to view.
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
    10
    """
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
    11
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
    12
    try:
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
    13
        event = Event.objects.all()[0]
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
    14
    except IndexError:
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
    15
        raise Http404
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
    ip = request.META['REMOTE_ADDR']
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
    18
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
    19
    can_submit_feedback = True if event.feedback_status != '0' and \
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
    20
            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
    21
    can_take_quiz = False
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
    22
8929b82c1dbb added home page with minimum functionality
nishanth
parents: 4
diff changeset
    23
    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
    24
7
dfedb369f32e first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents: 6
diff changeset
    25
def event_admin(request, key_word):
dfedb369f32e first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents: 6
diff changeset
    26
    """ see if the key is correct and then display options.
dfedb369f32e first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents: 6
diff changeset
    27
    """
dfedb369f32e first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents: 6
diff changeset
    28
dfedb369f32e first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents: 6
diff changeset
    29
    if not key_word == ADMIN_KEY:
dfedb369f32e first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents: 6
diff changeset
    30
        raise Http404
dfedb369f32e first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents: 6
diff changeset
    31
dfedb369f32e first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents: 6
diff changeset
    32
    try:
dfedb369f32e first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents: 6
diff changeset
    33
        event = Event.objects.all()[0]
dfedb369f32e first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents: 6
diff changeset
    34
    except IndexError:
dfedb369f32e first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents: 6
diff changeset
    35
        return redirect('/event/create/%s'%ADMIN_KEY)
dfedb369f32e first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents: 6
diff changeset
    36
dfedb369f32e first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents: 6
diff changeset
    37
    return render_to_response('admin.html', {'event':event, 'admin_key':ADMIN_KEY})
dfedb369f32e first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents: 6
diff changeset
    38
    
dfedb369f32e first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents: 6
diff changeset
    39
def event_create():
dfedb369f32e first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents: 6
diff changeset
    40
    pass
dfedb369f32e first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents: 6
diff changeset
    41
dfedb369f32e first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents: 6
diff changeset
    42