--- /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 @@
+<html>
+<head>
+<title>
+</title>
+</head>
+<body>
+<form action="" method="post">
+{{ form.as_p }}
+<input type="submit" value="submit">
+</form>
+</body>
+</html>
--- /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']
+
--- 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
+ )
--- /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),
+)
--- 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 <a href="/feedback/list">here</a>')
+ 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})
--- /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 @@
+<html>
+<head>
+<title>
+</title>
+</head>
+{% for feed in feeds %}
+ {{ feed }}<br />
+{% endfor %}
+<a href="/feedback/submit">submit another one here</a>
+</body>
+</html>
--- a/reg/views.py Fri Apr 09 12:28:58 2010 +0530
+++ b/reg/views.py Fri Apr 09 13:21:46 2010 +0530
@@ -52,7 +52,6 @@
"""
logout(request)
- print "logged out"
return redirect('/reg')
--- a/urls.py Fri Apr 09 12:28:58 2010 +0530
+++ b/urls.py Fri Apr 09 13:21:46 2010 +0530
@@ -17,5 +17,5 @@
(r'^reg/', include('workshop.reg.site.urls')),
#(r'^quiz/', include('workshop.quiz.site.urls')),
- #(r'^feedback/', include('workshop.feedback.site.urls')),
+ (r'^feedback/', include('workshop.feedback.site.urls')),
)