checking for admin key is done via urls in all the views related to feedback
authornishanth
Wed, 30 Jun 2010 10:42:32 +0530
changeset 73 5c2c74afb94e
parent 72 665287ab8e3a
child 74 46c5ae6594df
checking for admin key is done via urls in all the views related to feedback
event/views.py
feedback/views.py
urls.py
--- a/event/views.py	Wed Jun 30 10:33:03 2010 +0530
+++ b/event/views.py	Wed Jun 30 10:42:32 2010 +0530
@@ -43,10 +43,7 @@
 
     return render_to_response('admin.html', {'event':event, 'admin_key':ADMIN_KEY})
     
-def event_create(request, admin_key):
-
-    if not admin_key == ADMIN_KEY:
-        raise Http404
+def event_create(request):
 
     try:
         event = Event.objects.all()[0]
--- a/feedback/views.py	Wed Jun 30 10:33:03 2010 +0530
+++ b/feedback/views.py	Wed Jun 30 10:42:32 2010 +0530
@@ -54,13 +54,10 @@
         form = FeedbackForm()
         return render_to_response('submit_feedback.html',{'form':form, 'event':event})
 
-def open_feedback(request, admin_key):
-    """
-    Check for key and then exiatance of event.
+def open_feedback(request):
     """
-
-    if not admin_key == ADMIN_KEY:
-        raise Http404
+    Check for the existance of event.
+    """
 
     try:
         event = Event.objects.all()[0]
@@ -80,14 +77,11 @@
         day = event.feedback_status
         return render_to_response('open_feedback.html', {'success': True, 'day':day, 'event':event})
 
-def close_feedback(request, admin_key):
+def close_feedback(request):
     """
     simply set feedback status to 0
     """
 
-    if not admin_key == ADMIN_KEY:
-        raise Http404
-
     try:
         event = Event.objects.all()[0]
     except IndexError:
@@ -98,13 +92,10 @@
     event.save()
     return render_to_response('close_feedback.html', {'event': event, 'day':day, "admin_key":ADMIN_KEY})
 
-def list_feedbacks(request, admin_key):
+def list_feedbacks(request):
     """ print a list of all the feedbacks collected.
     """
 
-    if not admin_key == ADMIN_KEY:
-        raise Http404
-
     try:
         event = Event.objects.all()[0]
     except IndexError:
@@ -126,13 +117,10 @@
 
     return render_to_response('list_feedbacks.html',{'event':event, 'feeds_list':feeds_list})
 
-def view_report(request, admin_key):
+def view_report(request):
     """ compile the report and display it.
     """
 
-    if not admin_key == ADMIN_KEY:
-        raise Http404
-
     try:
         event = Event.objects.all()[0]
     except IndexError:
--- a/urls.py	Wed Jun 30 10:33:03 2010 +0530
+++ b/urls.py	Wed Jun 30 10:42:32 2010 +0530
@@ -23,13 +23,13 @@
 
     (r'^$', event_views.event_home),
     (r'^event/admin/%s$'%AK, event_views.event_admin),
-    (r'^event/create/(\w+)$', event_views.event_create),
+    (r'^event/create/%s$'%AK, event_views.event_create),
 
     (r'^feedback/submit$', feed_views.submit_feedback),
-    (r'^feedback/open/(\w+)$', feed_views.open_feedback),
-    (r'^feedback/close/(\w+)$', feed_views.close_feedback),
-    (r'^feedback/list/(\w+)$', feed_views.list_feedbacks),
-    (r'^feedback/report/(\w+)$', feed_views.view_report),
+    (r'^feedback/open/%s$'%AK, feed_views.open_feedback),
+    (r'^feedback/close/%s$'%AK, feed_views.close_feedback),
+    (r'^feedback/list/%s$'%AK, feed_views.list_feedbacks),
+    (r'^feedback/report/%s$'%AK, feed_views.view_report),
 
     (r'^quiz/open/(\w+)$', event_views.open_quiz),
     (r'^quiz/close/(\w+)$', event_views.close_quiz),