def new_bar(request): if 'new' in request.GET: bar = Bar() bar.save() return HttpResponseRedirect(reverse('faith:new')) return render_to_response('faith/new.html', {}, context_instance=RequestContext(request))
def main(request): try: bar = Bar.objects.latest("date_created") except Bar.DoesNotExist: bar = Bar() bar.save() has_voted = bar.has_voted(request.META["REMOTE_ADDR"]) return render_to_response( "index.html", {"has_voted": has_voted, "bar": bar}, context_instance=RequestContext(request) )
def track(request): try: bar = Bar.objects.latest('date_created') except Bar.DoesNotExist: bar = Bar() bar.save() has_voted = bar.has_voted(request.META['REMOTE_ADDR']) return render_to_response('faith/track.html', { 'has_voted': has_voted, 'bar': bar, }, context_instance=RequestContext(request))