# HG changeset patch # User nishanth # Date 1271051607 -19800 # Node ID 334550460bd7d5dbe250b235698a96f24740dfbd # Parent c52d170969f0eb8403a738238db7cd200e4d896c added the view event functionality and submitting feedback according to the status . diff -r c52d170969f0 -r 334550460bd7 feedback.html --- a/feedback.html Mon Apr 12 04:23:13 2010 +0530 +++ b/feedback.html Mon Apr 12 11:23:27 2010 +0530 @@ -1,7 +1,11 @@ {% extends "base.html" %} {% block content %} -
+ {% if submitted %} + Your feedback has been successfully submitted. + {% else %} + + {% endif %} {% endblock %} diff -r c52d170969f0 -r 334550460bd7 feedback/models.py --- a/feedback/models.py Mon Apr 12 04:23:13 2010 +0530 +++ b/feedback/models.py Mon Apr 12 11:23:27 2010 +0530 @@ -44,26 +44,24 @@ """ user_ip = models.CharField(max_length=15) - event = models.ForeignKey(Event) - day = models.PositiveIntegerField(default=1) + event = models.ForeignKey(Event, related_name="%(class)s") + day = models.CharField(max_length=1, default='1') - range_of_topics = models.CharField(max_length=1, choices=TOPICS_CHOICES, - verbose_name="Range of topics covered", blank=True) - depth_of_coverage = models.CharField(max_length=1, choices=DEPTH_CHOICES, blank=True) - effectiveness_of_methodology = models.CharField(max_length=1, choices=METHODOLOGY_CHOICES, blank=True) - pace_of_coverage = models.CharField(max_length=1, choices=PACE_CHOICES, blank=True) + topics = models.CharField(max_length=1, choices=TOPICS_CHOICES, + verbose_name="Range of topics covered", blank=True) + depth = models.CharField(max_length=1, choices=DEPTH_CHOICES, + verbose_name="Depth of coverage", blank=True) + methodology = models.CharField(max_length=1, choices=METHODOLOGY_CHOICES, + verbose_name="Effectiveness of methodology", blank=True) + pace = models.CharField(max_length=1, choices=PACE_CHOICES, + verbose_name="Pace of coverage", blank=True) applicability = models.CharField(max_length=1, choices=APPLICABILITY_CHOICES, blank=True) - choice_of_problems = models.CharField(max_length=1, choices=PROBLEMS_CHOICES, blank=True) - choice_of_exercises = models.CharField(max_length=1, choices=EXERCISES_CHOICES, blank=True) + problems = models.CharField(max_length=1, choices=PROBLEMS_CHOICES, + verbose_name="Choice of problems", blank=True) + exercises = models.CharField(max_length=1, choices=EXERCISES_CHOICES, + verbose_name="Choice of exercises", blank=True) comments = models.TextField(verbose_name="General comments", blank=True) def __unicode__(self): - return unicode(self.range_of_topics + - self.depth_of_coverage + - self.effectiveness_of_methodology + - self.pace_of_coverage + - self.applicability + - self.choice_of_problems + - self.choice_of_exercises - ) + return unicode(event.title) diff -r c52d170969f0 -r 334550460bd7 feedback/views.py --- a/feedback/views.py Mon Apr 12 04:23:13 2010 +0530 +++ b/feedback/views.py Mon Apr 12 11:23:27 2010 +0530 @@ -1,5 +1,7 @@ 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 @@ -10,14 +12,35 @@ if not, collect the feedback. """ - ip = request.META["REMOTE_ADDR"] - print 'ip', ip + try: + event = Event.objects.get(key=event_key) + except Event.DoesNotExist: + return redirect('/reg') + + if event.feedback_status == "0": + return redirect('/reg') + + 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: + 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(): - form.save() - return HttpResponse('Good. now click here') + 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: diff -r c52d170969f0 -r 334550460bd7 index.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/index.html Mon Apr 12 11:23:27 2010 +0530 @@ -0,0 +1,6 @@ +{% extends "base.html" %} +{% block content %} + {% for event in events %} + {{event.title}}