added date tags in view event template and open_feedback template is now a lil better .
from django.shortcuts import render_to_response, redirect
from workshop.reg.models import Event
from workshop.feedback.models import Feedback
from workshop.feedback.forms import FeedbackForm
from workshop.feedback.utils import compile_report
from django.http import HttpResponse
def submit_feedback(request, event_key):
""" see if the ip address has already submitted a feedback.
if not, collect the feedback.
"""
try:
event = Event.objects.get(key=event_key)
except Event.DoesNotExist:
raise Http404
if event.feedback_status == "0":
raise Http404
user_ip = request.META["REMOTE_ADDR"]
try:
old_feedback = Feedback.objects.get(day=event.feedback_status, user_ip=user_ip)
return render_to_response('feedback.html', {'submitted':True})
except Feedback.DoesNotExist:
new_feedback = Feedback(event=event, user_ip=user_ip, day=event.feedback_status)
if request.method == "POST":
form = FeedbackForm(request.POST)
if form.is_valid():
data = form.cleaned_data
new_feedback.topics = data['topics']
new_feedback.depth = data['depth']
new_feedback.methodology = data['methodology']
new_feedback.pace = data['pace']
new_feedback.applicability = data['applicability']
new_feedback.problems = data['problems']
new_feedback.exercises = data['exercises']
new_feedback.comments = data['comments']
new_feedback.save()
return render_to_response('feedback.html', {'submitted':True})
else:
return render_to_response('feedback.html',{'form':form})
else:
form = FeedbackForm()
return render_to_response('feedback.html',{'form':form})
def list_feedbacks(request, event_key):
""" print a list of all the feedbacks collected.
"""
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+1)
return render_to_response('list_feedbacks.html',{'user':user, 'event':event})