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 .

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, event_key):
    """ 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, event_key):
    """ print a list of all the feedbacks collected.
    """

    feeds = Feedback.objects.all()
    return render_to_response('list_feedbacks.html',{'feeds':feeds})