View to calculate the number of registrants per event.
authorMadhusudan.C.S <madhusudancs@gmail.com>
Tue, 02 Nov 2010 22:32:38 +0530
changeset 194 808abc104b55
parent 193 ed5828a90109
child 195 ec3f4b2e8d37
View to calculate the number of registrants per event.
project/scipycon/registration/views.py
project/static/css/styles.css
--- a/project/scipycon/registration/views.py	Tue Nov 02 22:13:12 2010 +0530
+++ b/project/scipycon/registration/views.py	Tue Nov 02 22:32:38 2010 +0530
@@ -256,63 +256,22 @@
 
 @login_required
 def regstats(request, scope,
-                 template_name='registration/regstats.html'):
+             template_name='registration/regstats.html'):
     """View that gives the statistics of registrants.
     """
-    from project.scipycon.registration.forms import RegistrationAdminSelectForm
+
     if not request.user.is_staff:
         redirect_to = reverse('scipycon_login', kwargs={'scope': scope})
 
-    if request.method == "POST":
-        form = RegistrationAdminSelectForm(request.POST)
-        if form.is_valid():
-            conference = form.cleaned_data['by_conference']
-            tutorial = form.cleaned_data['by_tutorial']
-            sprint = form.cleaned_data['by_sprint']
-            include = form.cleaned_data['include']
 
-            q = Registration.objects.all()
-            q = q.filter(conference=conference)
-            q = q.filter(tutorial=tutorial)
-            q = q.filter(sprint=sprint)
-
-            q = q.order_by('registrant__email')
-
-            query = q.query
-            results = list(q)
+    q = Registration.objects.all()
+    conf_num = q.filter(conference=True).count()
+    tut_num = q.filter(tutorial=True).count()
+    sprint_num = q.filter(sprint=True).count()
 
-            if include == []:
-                # default to include all fields
-                include = [i[0] for i in IC]
-            if results:
-                response = HttpResponse(mimetype='text/csv')
-                response['Content-Disposition'] = 'attachment; filename=registrations.csv'
-                output = csv.writer(response)
-                output.writerow([h for h in include])
-                for row in results:
-                    conference = row.conference == True and 'yes' or 'no'
-                    tutorial = row.tutorial == True and 'yes' or 'no'
-                    sprint = row.sprint == True and 'yes' or 'no'
-                    wrow = []
-                    if 'Name' in include:
-                        wrow.append(
-                            row.registrant.get_full_name().encode('utf-8'))
-                    if 'Email' in include:
-                        wrow.append(row.registrant.email.encode('utf-8'))
-                    if 'Organisation' in include:
-                        wrow.append(row.organisation.encode('utf-8'))
-                    if 'Conference' in include:
-                        wrow.append(conference)
-                    if 'Tutorial' in include:
-                        wrow.append(tutorial)
-                    if 'Sprint' in include:
-                        wrow.append(sprint)
-                    output.writerow(wrow)
-                return response
-            else:
-                no_results = u'No results found for the query'
-
-    else:
-        form = RegistrationAdminSelectForm()
     return render_to_response(template_name, RequestContext(request,
-        locals()))
+        {'params': {'scope': scope},
+         'conf_num': conf_num, 
+         'tut_num': tut_num,
+         'sprint_num': sprint_num,
+         }))
\ No newline at end of file
--- a/project/static/css/styles.css	Tue Nov 02 22:13:12 2010 +0530
+++ b/project/static/css/styles.css	Tue Nov 02 22:32:38 2010 +0530
@@ -113,6 +113,32 @@
     padding: 4px 6px;
 }
 
+table.scipycon-default-border
+{
+    border-width: 2px;
+    border-spacing: 2px;
+    border-style: outset;
+    border-color: gray;
+    border-collapse: separate;
+}
+
+table.scipycon-default-border td
+{
+    border-width: 1px;
+    padding: 5px 15px;
+    border-style: inset;
+    border-color: gray;
+}
+
+table.scipycon-default-border th
+{
+    border-width: 1px;
+    border-style: inset;
+    border-color: gray;
+    font-weight: bold;
+    padding: 4px 6px;
+}
+
 table.scipycon-default a
 {
     text-decoration: none;