# HG changeset patch
# User nishanth
# Date 1270799506 -19800
# Node ID 37e4027fba482cd47a74f539d4796fec80669c09
# Parent ededea9ad08bf820778ebaa2e4daa17ec8e202fc
submit and list feedback done
diff -r ededea9ad08b -r 37e4027fba48 feedback.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/feedback.html Fri Apr 09 13:21:46 2010 +0530
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
diff -r ededea9ad08b -r 37e4027fba48 feedback/forms.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/feedback/forms.py Fri Apr 09 13:21:46 2010 +0530
@@ -0,0 +1,12 @@
+from django import forms
+
+from workshop.feedback.models import Feedback
+
+class FeedbackForm(forms.ModelForm):
+ """ A form to collect the feedback.
+ """
+
+ class Meta:
+ model = Feedback
+ exclude = ['user_ip']
+
diff -r ededea9ad08b -r 37e4027fba48 feedback/models.py
--- a/feedback/models.py Fri Apr 09 12:28:58 2010 +0530
+++ b/feedback/models.py Fri Apr 09 13:21:46 2010 +0530
@@ -53,6 +53,16 @@
pace_of_coverage = models.CharField(max_length=1, choices=PACE_CHOICES, 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)
- chocice_of_exercises = models.CharField(max_length=1, choices=EXERCISES_CHOICES, blank=True)
+ choice_of_exercises = models.CharField(max_length=1, choices=EXERCISES_CHOICES, 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
+ )
diff -r ededea9ad08b -r 37e4027fba48 feedback/site/__init__.py
diff -r ededea9ad08b -r 37e4027fba48 feedback/site/urls.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/feedback/site/urls.py Fri Apr 09 13:21:46 2010 +0530
@@ -0,0 +1,8 @@
+from django.conf.urls.defaults import *
+
+from workshop.feedback import views as feed_views
+
+urlpatterns = patterns('',
+ ('^submit$', feed_views.submit_feedback),
+ ('^list$', feed_views.list_feedbacks),
+)
diff -r ededea9ad08b -r 37e4027fba48 feedback/views.py
--- a/feedback/views.py Fri Apr 09 12:28:58 2010 +0530
+++ b/feedback/views.py Fri Apr 09 13:21:46 2010 +0530
@@ -1,1 +1,32 @@
-# Create your views here.
+from django.shortcuts import render_to_response, redirect
+
+from workshop.feedback.models import Feedback
+from workshop.feedback.forms import FeedbackForm
+
+from django.http import HttpResponse
+
+def submit_feedback(request):
+ """ see if the ip address has already submitted a feedback.
+ if not, collect the feedback.
+ """
+
+ ip = request.META["REMOTE_ADDR"]
+ print 'ip', ip
+
+ if request.method == "POST":
+ form = FeedbackForm(request.POST)
+ if form.is_valid():
+ form.save()
+ return HttpResponse('Good. now click here')
+ else:
+ return render_to_response('feedback.html',{'form':form})
+ else:
+ form = FeedbackForm()
+ return render_to_response('feedback.html',{'form':form})
+
+def list_feedbacks(request):
+ """ print a list of all the feedbacks collected.
+ """
+
+ feeds = Feedback.objects.all()
+ return render_to_response('list_feedbacks.html',{'feeds':feeds})
diff -r ededea9ad08b -r 37e4027fba48 list_feedbacks.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/list_feedbacks.html Fri Apr 09 13:21:46 2010 +0530
@@ -0,0 +1,11 @@
+
+
+
+
+
+{% for feed in feeds %}
+ {{ feed }}
+{% endfor %}
+submit another one here
+
+