added closing and opening of feedback.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/close_feedback.html Mon Apr 12 12:08:19 2010 +0530
@@ -0,0 +1,5 @@
+{% extends "base.html" %}
+{% block content %}
+ Feedback for day {{day}} of {{event.title}} has been successfully closed.<br />
+ <a href="/reg/event/view/{{event.key}}">Click here</a> to return to the event page.
+{% endblock %}
--- a/feedback/models.py Mon Apr 12 11:23:27 2010 +0530
+++ b/feedback/models.py Mon Apr 12 12:08:19 2010 +0530
@@ -64,4 +64,4 @@
def __unicode__(self):
- return unicode(event.title)
+ return unicode(self.event.title)
--- a/list_feedbacks.html Mon Apr 12 11:23:27 2010 +0530
+++ b/list_feedbacks.html Mon Apr 12 12:08:19 2010 +0530
@@ -3,5 +3,4 @@
{% for feed in feeds %}
{{ feed }}<br />
{% endfor %}
-<a href="/feedback/submit">submit another one here</a>
{% endblock %}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/open_feedback.html Mon Apr 12 12:08:19 2010 +0530
@@ -0,0 +1,18 @@
+{% extends "base.html" %}
+{% block content %}
+ {% if success %}
+ The feedback for day {{day}} of {{event.title}} has been opened.<br />
+ <a href="/reg/event/view/{{event.key}}">Click here</a> to return to the event page.
+ {% else %}
+ Select the day for workshop {{event.title}} to start accepting feedbacks.
+ <form action="" method="post">
+ Day:<br />
+ <select name="day">
+ {% for day in days %}
+ <option value="{{day}}">Day {{day}}</option>
+ {% endfor %}
+ </select>
+ <input value="Open" type="submit">
+ </form>
+ {% endif %}
+{% endblock %}
--- a/reg/site/urls.py Mon Apr 12 11:23:27 2010 +0530
+++ b/reg/site/urls.py Mon Apr 12 12:08:19 2010 +0530
@@ -11,4 +11,6 @@
(r'^password_change/$', reg_views.change_password),
(r'^event/create/$', reg_views.create_event),
(r'^event/view/(\w+)/$', reg_views.view_event),
+ (r'^event/feedback/open/(\w+)', reg_views.open_feedback),
+ (r'^event/feedback/close/(\w+)', reg_views.close_feedback),
)
--- a/reg/views.py Mon Apr 12 11:23:27 2010 +0530
+++ b/reg/views.py Mon Apr 12 12:08:19 2010 +0530
@@ -180,9 +180,52 @@
form = reg_forms.PasswordChangeForm()
return render_to_response('password_change.html', {'form':form})
+def open_feedback(request, event_key):
+ """ see if the event exists.
+ then see if feedback is closed.
+ then give option for opening the feedback.
+ Any feedback can be opened on any day.
+ """
+ user = request.user
+ try:
+ event = Event.objects.get(key__iexact=event_key)
+ except Event.DoesNotExist:
+ return redirect("/reg")
+ is_org = True if user in event.organizers.all() else False
-
+ if is_org and event.feedback_status == '0':
+ #days = event.stop_date.day() - event.start_date.day() + 1
+ days = 2
+ if request.method == "POST":
+ day = request.POST['day']
+ event.feedback_status = day
+ event.save()
+ return render_to_response('open_feedback.html', {'success': True, 'day':day, 'event':event})
+ else:
+ return render_to_response('open_feedback.html', {'event': event, 'days': range(1,days+1)})
+ else:
+ return redirect('/reg')
+def close_feedback(request, event_key):
+ """ check if the user is org.
+ and then check if the feedback is open already.
+ """
+ user = request.user
+ try:
+ event = Event.objects.get(key__iexact=event_key)
+ except Event.DoesNotExist:
+ return redirect("/reg")
+
+ is_org = True if user in event.organizers.all() else False
+
+ if is_org:
+ day = event.feedback_status
+ event.feedback_status = '0'
+ event.save()
+ return render_to_response('close_feedback.html', {'event': event, 'day':day})
+ else:
+ return redirect('/reg')
+
--- a/view_event.html Mon Apr 12 11:23:27 2010 +0530
+++ b/view_event.html Mon Apr 12 12:08:19 2010 +0530
@@ -14,6 +14,7 @@
{% if can_submit_feedback %}
<a href="/feedback/submit/{{event.key}}">Click here</a> to submit feedback for today's session.<br />
+ {% endif %}
{% if is_org %}
{% if event.registration_is_open %}
@@ -22,20 +23,18 @@
<a href="/reg/event/registration/open/{{event.key}}">Click here</a> to open the registration.<br />
{% endif %}
- {% ifequal quiz_status "00" %}
+ {% ifequal event.quiz_status "00" %}
<a href="/reg/event/quiz/open/{{event.key}}">Click here</a> to open quiz.<br />
{% else %}
<a href="/reg/event/registration/close/{{event.key}}">Click here</a> to close the registration.<br />
{% endifequal %}
- {% ifequal feedback_status "0" %}
+ {% ifequal event.feedback_status "0" %}
<a href="/reg/event/feedback/open/{{event.key}}">Click here</a> to open the feedback.<br />
{% else %}
<a href="/feedback/list/{{event.key}}">Click here</a> to see the feedbacks that we submitted.<br />
- <a href="/reg/event/feedback/open/{{event.key}}">Click here</a> to close the feedback.<br />
+ <a href="/reg/event/feedback/close/{{event.key}}">Click here</a> to close the feedback for day {{event.feedback_status}}.<br />
{% endifequal %}
{% endif %}
-
-
- {% endif %}
+
{% endblock %}