added view report functionality. have to make it look better.
--- a/feedback/site/urls.py Thu Apr 15 12:38:29 2010 +0530
+++ b/feedback/site/urls.py Thu Apr 15 13:59:46 2010 +0530
@@ -5,4 +5,5 @@
urlpatterns = patterns('',
('^submit/(\w+)$', feed_views.submit_feedback),
('^list/(\w+)$', feed_views.list_feedbacks),
+ ('^report/(\w+)$', feed_views.view_report),
)
--- a/feedback/views.py Thu Apr 15 12:38:29 2010 +0530
+++ b/feedback/views.py Thu Apr 15 13:59:46 2010 +0530
@@ -4,7 +4,7 @@
from workshop.feedback.models import Feedback
from workshop.feedback.forms import FeedbackForm
-from workshop.feedback.utils import compile_report
+from workshop.feedback.utils import make_day_report
from django.http import HttpResponse
@@ -73,7 +73,32 @@
for feed in day_feeds:
day_list.append(" ".join((feed.topics, feed.depth, feed.methodology, feed.pace,
feed.applicability, feed.problems, feed.exercises, feed.comments)))
- feeds_list.append(["Day %s"%day, day_list])
+ feeds_list.extend(["Day %s"%day, day_list])
return render_to_response('list_feedbacks.html',{'user':user, 'event':event, 'feeds_list':feeds_list})
+def view_report(request, event_key):
+ """ compile the report and display it.
+ """
+
+ user = request.user
+
+ try:
+ event = Event.objects.get(key__iexact=event_key)
+ except Event.DoesNotExist:
+ raise Http404
+
+ if not user in event.organizers.all():
+ raise Http404
+
+ no_of_days = (event.stop_date - event.start_date).days
+ days = range(1,no_of_days+2)
+
+ workshop_report = []
+
+ for day in days:
+ day_num = str(day)
+ day_feeds = Feedback.objects.filter(event=event,day=day_num)
+ workshop_report.extend( [ "Day %s"%day_num, make_day_report(day_feeds) ] )
+
+ return render_to_response("show_report.html", {"user":user, "event":event, "workshop_report":workshop_report})
--- a/templates/list_feedbacks.html Thu Apr 15 12:38:29 2010 +0530
+++ b/templates/list_feedbacks.html Thu Apr 15 13:59:46 2010 +0530
@@ -2,7 +2,5 @@
{% block content %}
List of feedbacks submitted for the workshop <a href="/reg/event/view/{{event.key}}">{{event.title}}</a>
<br />
-{% for day_list in feeds_list %}
- {{day_list|unordered_list}}
-{% endfor %}
+{{feeds_list|unordered_list}}
{% endblock %}
--- a/templates/view_event.html Thu Apr 15 12:38:29 2010 +0530
+++ b/templates/view_event.html Thu Apr 15 13:59:46 2010 +0530
@@ -25,8 +25,8 @@
<br />
{% if is_org %}
<a href="/reg/event/attendees/{{event.key}}">View list of people registered for the workshop</a> <br />
- <a href="/feedback/list/{{event.key}}">View submitted feedbacks</a><br /><br />
- <a href="/feedback/report/{{event.key}}">View a report of the workshop</a>
+ <a href="/feedback/list/{{event.key}}">View submitted feedbacks</a><br />
+ <a href="/feedback/report/{{event.key}}">View a report of the workshop</a><br /><br />
{% if user.is_staff %}
{% if event.registration_is_open %}
<a href="/reg/event/registration/close/{{event.key}}">Close the registration</a><br />