author | nishanth |
Tue, 13 Apr 2010 16:29:58 +0530 | |
changeset 36 | cd0f61fa31f1 |
parent 35 | 79dc44b6edd4 |
child 38 | b63b78017225 |
permissions | -rw-r--r-- |
5 | 1 |
from django.shortcuts import render_to_response, redirect |
2 |
||
11
334550460bd7
added the view event functionality and submitting feedback according to the status .
nishanth
parents:
10
diff
changeset
|
3 |
from workshop.reg.models import Event |
334550460bd7
added the view event functionality and submitting feedback according to the status .
nishanth
parents:
10
diff
changeset
|
4 |
|
5 | 5 |
from workshop.feedback.models import Feedback |
6 |
from workshop.feedback.forms import FeedbackForm |
|
7 |
||
8 |
from django.http import HttpResponse |
|
9 |
||
10
c52d170969f0
quite a few changes. modified models and feedback views .
nishanth
parents:
5
diff
changeset
|
10 |
def submit_feedback(request, event_key): |
5 | 11 |
""" see if the ip address has already submitted a feedback. |
12 |
if not, collect the feedback. |
|
13 |
""" |
|
14 |
||
11
334550460bd7
added the view event functionality and submitting feedback according to the status .
nishanth
parents:
10
diff
changeset
|
15 |
try: |
334550460bd7
added the view event functionality and submitting feedback according to the status .
nishanth
parents:
10
diff
changeset
|
16 |
event = Event.objects.get(key=event_key) |
334550460bd7
added the view event functionality and submitting feedback according to the status .
nishanth
parents:
10
diff
changeset
|
17 |
except Event.DoesNotExist: |
35 | 18 |
raise Http404 |
11
334550460bd7
added the view event functionality and submitting feedback according to the status .
nishanth
parents:
10
diff
changeset
|
19 |
|
334550460bd7
added the view event functionality and submitting feedback according to the status .
nishanth
parents:
10
diff
changeset
|
20 |
if event.feedback_status == "0": |
35 | 21 |
raise Http404 |
11
334550460bd7
added the view event functionality and submitting feedback according to the status .
nishanth
parents:
10
diff
changeset
|
22 |
|
334550460bd7
added the view event functionality and submitting feedback according to the status .
nishanth
parents:
10
diff
changeset
|
23 |
user_ip = request.META["REMOTE_ADDR"] |
334550460bd7
added the view event functionality and submitting feedback according to the status .
nishanth
parents:
10
diff
changeset
|
24 |
try: |
334550460bd7
added the view event functionality and submitting feedback according to the status .
nishanth
parents:
10
diff
changeset
|
25 |
old_feedback = Feedback.objects.get(day=event.feedback_status, user_ip=user_ip) |
334550460bd7
added the view event functionality and submitting feedback according to the status .
nishanth
parents:
10
diff
changeset
|
26 |
return render_to_response('feedback.html', {'submitted':True}) |
35 | 27 |
except Feedback.DoesNotExist: |
11
334550460bd7
added the view event functionality and submitting feedback according to the status .
nishanth
parents:
10
diff
changeset
|
28 |
new_feedback = Feedback(event=event, user_ip=user_ip, day=event.feedback_status) |
5 | 29 |
|
30 |
if request.method == "POST": |
|
31 |
form = FeedbackForm(request.POST) |
|
32 |
if form.is_valid(): |
|
11
334550460bd7
added the view event functionality and submitting feedback according to the status .
nishanth
parents:
10
diff
changeset
|
33 |
data = form.cleaned_data |
334550460bd7
added the view event functionality and submitting feedback according to the status .
nishanth
parents:
10
diff
changeset
|
34 |
new_feedback.topics = data['topics'] |
334550460bd7
added the view event functionality and submitting feedback according to the status .
nishanth
parents:
10
diff
changeset
|
35 |
new_feedback.depth = data['depth'] |
334550460bd7
added the view event functionality and submitting feedback according to the status .
nishanth
parents:
10
diff
changeset
|
36 |
new_feedback.methodology = data['methodology'] |
334550460bd7
added the view event functionality and submitting feedback according to the status .
nishanth
parents:
10
diff
changeset
|
37 |
new_feedback.pace = data['pace'] |
334550460bd7
added the view event functionality and submitting feedback according to the status .
nishanth
parents:
10
diff
changeset
|
38 |
new_feedback.applicability = data['applicability'] |
334550460bd7
added the view event functionality and submitting feedback according to the status .
nishanth
parents:
10
diff
changeset
|
39 |
new_feedback.problems = data['problems'] |
334550460bd7
added the view event functionality and submitting feedback according to the status .
nishanth
parents:
10
diff
changeset
|
40 |
new_feedback.exercises = data['exercises'] |
334550460bd7
added the view event functionality and submitting feedback according to the status .
nishanth
parents:
10
diff
changeset
|
41 |
new_feedback.comments = data['comments'] |
334550460bd7
added the view event functionality and submitting feedback according to the status .
nishanth
parents:
10
diff
changeset
|
42 |
new_feedback.save() |
334550460bd7
added the view event functionality and submitting feedback according to the status .
nishanth
parents:
10
diff
changeset
|
43 |
return render_to_response('feedback.html', {'submitted':True}) |
5 | 44 |
else: |
45 |
return render_to_response('feedback.html',{'form':form}) |
|
46 |
else: |
|
47 |
form = FeedbackForm() |
|
48 |
return render_to_response('feedback.html',{'form':form}) |
|
49 |
||
10
c52d170969f0
quite a few changes. modified models and feedback views .
nishanth
parents:
5
diff
changeset
|
50 |
def list_feedbacks(request, event_key): |
5 | 51 |
""" print a list of all the feedbacks collected. |
52 |
""" |
|
53 |
||
36 | 54 |
user = request.user |
55 |
||
56 |
try: |
|
57 |
event = Event.objects.get(key__iexact=event_key) |
|
58 |
except Event.DoesNotExist: |
|
59 |
raise Http404 |
|
60 |
||
61 |
if not user in event.organizers.all(): |
|
62 |
raise Http404 |
|
63 |
||
64 |
feeds = Feedback.objects.filter(event=event) |
|
5 | 65 |
return render_to_response('list_feedbacks.html',{'feeds':feeds}) |
36 | 66 |