def rate_dataset(request, item_id, input_rating=None, slug=None): if input_rating: pass else: if request.method != 'POST': #show them the rate form form = RatingDataSetForm() else: # handle the submission of their rate form form = RatingDataSetForm(request.POST) if form.is_valid(): rating = int(form.cleaned_data['rating']) #TODO: why doesn't it just return an int? ip_address = request.META['REMOTE_ADDR'] user = request.user dataset = DataSet.objects.get(pk = item_id) dataset.rating.add(rating, user, ip_address) dataset.save() return HttpResponseRedirect(reverse('epic.datasets.views.view_dataset', kwargs={'item_id':dataset.id, 'slug':slug,})) else: #print request.POST # form.errors pass return render_to_response('datasets/rate_dataset.html', {'form':form, 'user':request.user, 'item':dataset,})
def rate_dataset(request, item_id, input_rating=None, slug=None): if input_rating: # TODO: surely this isn't supposed to be pass?! What used to be here? Won't it complain if no response is returned?! pass else: if request.method != 'POST': #show them the rate form form = RatingDataSetForm() else: # handle the submission of their rate form form = RatingDataSetForm(request.POST) if form.is_valid(): rating = int(form.cleaned_data['rating']) #TODO: why doesn't it just return an int? ip_address = request.META['REMOTE_ADDR'] user = request.user dataset = DataSet.objects.get(pk = item_id) dataset.rating.add(rating, user, ip_address) dataset.save() return HttpResponseRedirect(reverse('epic.datasets.views.view_dataset', kwargs={'item_id':dataset.id, 'slug':slug,})) else: pass return render_to_response( 'datasets/rate_dataset.html', {'form': form, 'item': dataset,}, context_instance=RequestContext(request))
def rate_dataset(request, item_id, input_rating=None, slug=None): if input_rating: # TODO: surely this isn't supposed to be pass?! What used to be here? Wont' it complain if no response is returned?! pass else: if request.method != "POST": # show them the rate form form = RatingDataSetForm() else: # handle the submission of their rate form form = RatingDataSetForm(request.POST) if form.is_valid(): rating = int(form.cleaned_data["rating"]) # TODO: why doesn't it just return an int? ip_address = request.META["REMOTE_ADDR"] user = request.user dataset = DataSet.objects.get(pk=item_id) dataset.rating.add(rating, user, ip_address) dataset.save() return HttpResponseRedirect( reverse("epic.datasets.views.view_dataset", kwargs={"item_id": dataset.id, "slug": slug}) ) else: # print request.POST # form.errors pass return render_to_response( "datasets/rate_dataset.html", {"form": form, "item": dataset}, context_instance=RequestContext(request) )