feedback/views.py
author nishanth
Mon, 12 Apr 2010 04:23:13 +0530
changeset 10 c52d170969f0
parent 5 37e4027fba48
child 11 334550460bd7
permissions -rw-r--r--
quite a few changes. modified models and feedback views .
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
     1
from django.shortcuts import render_to_response, redirect
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
     2
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
     3
from workshop.feedback.models import Feedback
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
     4
from workshop.feedback.forms import FeedbackForm
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
     5
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
     6
from django.http import HttpResponse
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
     7
10
c52d170969f0 quite a few changes. modified models and feedback views .
nishanth
parents: 5
diff changeset
     8
def submit_feedback(request, event_key):
5
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
     9
    """ see if the ip address has already submitted a feedback.
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
    10
    if not, collect the feedback.
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
    11
    """
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
    12
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
    13
    ip = request.META["REMOTE_ADDR"]
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
    14
    print 'ip', ip
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
    15
    
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
    16
    if request.method == "POST":
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
    17
        form = FeedbackForm(request.POST)
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
    18
        if form.is_valid():
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
    19
            form.save()
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
    20
            return HttpResponse('Good. now click <a href="/feedback/list">here</a>')
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
    21
        else:
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
    22
            return render_to_response('feedback.html',{'form':form})
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
    23
    else:
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
    24
        form = FeedbackForm()
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
    25
        return render_to_response('feedback.html',{'form':form})
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
    26
10
c52d170969f0 quite a few changes. modified models and feedback views .
nishanth
parents: 5
diff changeset
    27
def list_feedbacks(request, event_key):
5
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
    28
    """ print a list of all the feedbacks collected.
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
    29
    """
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
    30
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
    31
    feeds = Feedback.objects.all()
37e4027fba48 submit and list feedback done
nishanth
parents: 0
diff changeset
    32
    return render_to_response('list_feedbacks.html',{'feeds':feeds})