author | nishanth |
Tue, 20 Apr 2010 01:31:45 +0530 | |
changeset 7 | dfedb369f32e |
parent 5 | 9a671f3eb24c |
child 8 | 182e4a773ef2 |
permissions | -rw-r--r-- |
5 | 1 |
from django.shortcuts import render_to_response |
2 |
from django.http import Http404 |
|
3 |
||
4 |
from offline.event.models import Event |
|
5 |
||
6 |
from offline.feedback.models import Feedback |
|
7 |
from offline.feedback.forms import FeedbackForm |
|
8 |
||
9 |
||
10 |
def submit_feedback(request): |
|
11 |
||
12 |
""" see if the ip address has already submitted a feedback. |
|
13 |
if not, collect the feedback. |
|
14 |
""" |
|
15 |
||
16 |
try: |
|
17 |
event = Event.objects.all()[0] |
|
18 |
except IndexError: |
|
19 |
raise Http404 |
|
20 |
||
21 |
if event.feedback_status == "0": |
|
22 |
raise Http404 |
|
23 |
else: |
|
24 |
day = event.feedback_status |
|
25 |
||
26 |
ip = request.META['REMOTE_ADDR'] |
|
27 |
||
28 |
try: |
|
29 |
Feedback.objects.get(event=event,day=day,user_ip=ip) |
|
30 |
return render_to_response('submit_feedback.html', {'submitted':True, 'event':event}) |
|
31 |
except Feedback.DoesNotExist: |
|
32 |
new_feedback = Feedback(event=event,day=day,user_ip=ip) |
|
33 |
||
34 |
if request.method == "POST": |
|
35 |
form = FeedbackForm(request.POST) |
|
36 |
if form.is_valid(): |
|
37 |
data = form.cleaned_data |
|
38 |
new_feedback.topics = data['topics'] |
|
39 |
new_feedback.depth = data['depth'] |
|
40 |
new_feedback.methodology = data['methodology'] |
|
41 |
new_feedback.pace = data['pace'] |
|
42 |
new_feedback.applicability = data['applicability'] |
|
43 |
new_feedback.problems = data['problems'] |
|
44 |
new_feedback.exercises = data['exercises'] |
|
45 |
new_feedback.comments = data['comments'] |
|
46 |
new_feedback.save() |
|
47 |
||
48 |
return render_to_response('submit_feedback.html', {'submitted':True, 'event':event}) |
|
49 |
else: |
|
50 |
return render_to_response('submit_feedback.html',{ 'form':form, 'event':event}) |
|
51 |
else: |
|
52 |
form = FeedbackForm() |
|
53 |
return render_to_response('submit_feedback.html',{'form':form, 'event':event}) |
|
54 |
||
7
dfedb369f32e
first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents:
5
diff
changeset
|
55 |
def open_feedback(): |
dfedb369f32e
first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents:
5
diff
changeset
|
56 |
pass |
dfedb369f32e
first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents:
5
diff
changeset
|
57 |
|
dfedb369f32e
first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents:
5
diff
changeset
|
58 |
def close_feedback(): |
dfedb369f32e
first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents:
5
diff
changeset
|
59 |
pass |
dfedb369f32e
first fixed on the urls and then gave the admin_key in settings and then created main admin page.
nishanth
parents:
5
diff
changeset
|
60 |