upload/views.py
changeset 12 10d86ada90c2
parent 5 a1fe7806d6a0
child 16 b5bc2bff3055
--- a/upload/views.py	Sun Jan 24 14:58:51 2010 +0530
+++ b/upload/views.py	Mon Jan 25 01:20:43 2010 +0530
@@ -2,11 +2,12 @@
 from django.http import HttpResponse
 from django.template import Context, Template
 from django.shortcuts import render_to_response
+from django.contrib.auth.decorators import login_required
 
 from forms import ParticipantForm
 from models import Participant
 
-def upload_file(request, template_name='index.html'):
+def register_user(request, template_name='index.html'):
     if request.method == 'POST':
         form = ParticipantForm(request.POST, request.FILES)		
         if form.is_valid():            
@@ -16,3 +17,26 @@
             return render_to_response(template_name, {'form': form, 'value': True,})
     return render_to_response(template_name,
 			  {'form': ParticipantForm(), 'value': True})
+
+#@login_required
+def view_registrants(request, template_name='registrants.html'):
+    """
+    View to return list of registered participants
+    """
+    ##wow what a one liner
+    poc = dict([line.strip().split('|') for line in open('upload/poc')])        
+    if not request.user.is_authenticated():
+        return HttpResponse("You can't view these details.")
+    context_registrants = []
+
+    registrations = Participant.objects.all()
+    for registrant in registrations:
+        if poc[request.user.username] == registrant.workshop:
+            context_registrants.append({
+                'registrant':registrant,
+                })
+    context = {
+        'registrants':context_registrants,
+        }
+    return render_to_response(template_name, context)
+