quiz/views.py
changeset 14 ea7d372bfbff
parent 13 ad193c5014b2
child 15 99af908a4174
--- a/quiz/views.py	Tue Apr 20 15:39:07 2010 +0530
+++ b/quiz/views.py	Tue Apr 20 15:44:43 2010 +0530
@@ -1,10 +1,14 @@
 from django.db import IntegrityError
 
+from django.http import Http404
+
 from django.contrib.auth.models import User
 from django.contrib.auth import login, logout, authenticate
 
 from django.shortcuts import redirect, render_to_response
 
+from offline.event.models import Event
+
 from offline.quiz.utils import gen_key
 from offline.quiz.models import Profile
 
@@ -16,12 +20,20 @@
     Else register the user
     """
 
+    try:
+        event = Event.objects.all()[0]
+    except IndexError:
+        raise Http404
+    
+    if event.quiz_status == '00':
+        raise Http404
+
     user = request.user
     if user.is_authenticated():
         return redirect("/quiz/start/%s"%user.username)
 
     try:
-        Quiz.objects.get(user_ip=ip)
+        Quiz.objects.get(event=event,user_ip=ip,quiz_num=event.quiz_status)
         return redirect("/quiz/complete")
     except Quiz.DoesNotExist:
         pass