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):
""" 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):
""" print a list of all the feedbacks collected.
"""
feeds = Feedback.objects.all()
return render_to_response('list_feedbacks.html',{'feeds':feeds})