added the view event functionality and submitting feedback according to the status .
--- 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 %}
-<form action="" method="post">
-{{ form.as_p }}
-<input type="submit" value="submit">
-</form>
+ {% if submitted %}
+ Your feedback has been successfully submitted.
+ {% else %}
+ <form action="" method="post">
+ {{ form.as_p }}
+ <input type="submit" value="submit">
+ </form>
+ {% endif %}
{% endblock %}
--- 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)
--- 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 <a href="/feedback/list">here</a>')
+ 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:
--- /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 %}
+ <a href="/reg/event/view/{{event.key}}">{{event.title}}</a><br />
+ {% endfor %}
+{% endblock %}
--- a/reg/models.py Mon Apr 12 04:23:13 2010 +0530
+++ b/reg/models.py Mon Apr 12 11:23:27 2010 +0530
@@ -8,15 +8,15 @@
('F', 'Faculty'),
('P', 'Professional'))
-FEEDBACK_CHOICES = (('0': 'Closed'),
- ('1': 'Day 1 Open'),
- ('2': 'Day 2 Open'),
+FEEDBACK_CHOICES = (('0', 'Closed'),
+ ('1', 'Day 1 Open'),
+ ('2', 'Day 2 Open'),
)
-QUIZ_CHOICES = (('00': 'Closed'),
- ('11': 'Day1 Quiz1 Open'),
- ('12': 'Day1 Quiz2 Open'),
- ('21': 'Day2 Quiz1 Open'),
+QUIZ_CHOICES = (('00', 'Closed'),
+ ('11', 'Day1 Quiz1 Open'),
+ ('12', 'Day1 Quiz2 Open'),
+ ('21', 'Day2 Quiz1 Open'),
)
class Profile(models.Model):
@@ -45,7 +45,7 @@
attendees = models.ManyToManyField(User, related_name="%(class)s_attendees")
organizers = models.ManyToManyField(User, related_name="%(class)s_organizers")
- registration_status = models.BooleanField(default=False)
+ registration_is_open = models.BooleanField(default=False)
feedback_status = models.CharField(max_length=1, choices=FEEDBACK_CHOICES, default='0')
quiz_status = models.CharField(max_length=2, choices=QUIZ_CHOICES, default='00')
--- a/reg/views.py Mon Apr 12 04:23:13 2010 +0530
+++ b/reg/views.py Mon Apr 12 11:23:27 2010 +0530
@@ -8,6 +8,8 @@
from workshop.reg import forms as reg_forms
from workshop.reg import events as reg_events
+from workshop.feedback.models import Feedback
+
from django.http import HttpResponse
def homepage(request):
@@ -20,6 +22,8 @@
events = Event.objects.all()[:10]
+ return render_to_response('index.html', {'events':events})
+
def user_login(request):
""" get the user object from e-mail and then check for password.
"""
@@ -106,6 +110,7 @@
"""
user = request.user
+ user_ip = request.META['REMOTE_ADDR']
try:
event = Event.objects.get(key__iexact=key)
@@ -116,9 +121,18 @@
is_attendee = True if user in event.attendees.all() else False
is_org = True if user in event.organizers.all() else False
+ can_submit_feedback = False
+ if not event.feedback_status == "0":
+ try:
+ event.feedback.get(user_ip__iexact=user_ip, day=event.feedback_status)
+ except Feedback.DoesNotExist:
+ can_submit_feedback = True
+
context = {'is_guest': is_guest,
+ 'event': event,
'is_attendee': is_attendee,
'is_org': is_org,
+ 'can_submit_feedback': can_submit_feedback,
}
return render_to_response('view_event.html', context)
--- a/urls.py Mon Apr 12 04:23:13 2010 +0530
+++ b/urls.py Mon Apr 12 11:23:27 2010 +0530
@@ -13,7 +13,7 @@
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
- (r'^admin/', include(admin.site.urls)),
+ (r'^reg_admin/', include(admin.site.urls)),
(r'^reg/', include('workshop.reg.site.urls')),
#(r'^quiz/', include('workshop.quiz.site.urls')),
--- a/view_event.html Mon Apr 12 04:23:13 2010 +0530
+++ b/view_event.html Mon Apr 12 11:23:27 2010 +0530
@@ -1,4 +1,41 @@
{% extends "base.html" %}
{% block content %}
-
+ <h3>{{ event.title }}</h3><br />
+ Description:<br />
+ {{event.description}}<br />
+ duration of the workshop: {{event.start_date}} to {{event.stop_date}}<br />
+ {% if not is_guest %}
+ {% if is_attendee %}
+ You have registered for this workshop.
+ {% else %}
+ <a href="/reg/event/register/{{event.key}}">Click here</a> to register for the workshop.<br />
+ {% endif %}
+ {% endif %}
+
+ {% if can_submit_feedback %}
+ <a href="/feedback/submit/{{event.key}}">Click here</a> to submit feedback for today's session.<br />
+
+ {% if is_org %}
+ {% if event.registration_is_open %}
+ <a href="/reg/event/registration/close/{{event.key}}">Click here</a> to close the registration.<br />
+ {% else %}
+ <a href="/reg/event/registration/open/{{event.key}}">Click here</a> to open the registration.<br />
+ {% endif %}
+
+ {% ifequal 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" %}
+ <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 />
+ {% endifequal %}
+ {% endif %}
+
+
+ {% endif %}
{% endblock %}