Added date display to review html.

This commit is contained in:
Andrew Lalis 2018-10-03 23:08:57 +02:00
parent fbb0c890a1
commit a8597b1ce4
3 changed files with 9 additions and 8 deletions

Binary file not shown.

View File

@ -1,4 +1,7 @@
{# Template for displaying one review. #}
<h4>{{ review.title }}</h4> {{ review.rating }}
<h4>{{ review.title }}</h4>
<i>Rating: {{ review.rating }}</i><br>
<i>Posted on {{ review.created_date|date:"j M, Y" }}</i><br>
<p>{{ review.content }}</p>

View File

@ -59,7 +59,10 @@ def post_review(request):
title = form.cleaned_data['title']
content = form.cleaned_data['content']
entity_id = form.cleaned_data['entity_id']
try:
entity = RateableEntity.objects.get(pk=entity_id)
except RateableEntity.DoesNotExist:
raise HttpResponseBadRequest("Bad Request: Invalid entity id.")
# Creates the new Review object from the posted data.
review = Review.objects.create(
@ -70,11 +73,6 @@ def post_review(request):
)
# Send the user back to the entity they were viewing.
redirect_path = '/'
if entity.entity_type == RateableEntity.UNIVERSITY:
redirect_path = '/universities/' + str(entity_id)
elif entity.entity_type == RateableEntity.COURSE:
redirect_path = '/courses/' + str(entity_id)
return HttpResponseRedirect(redirect_path)
return HttpResponseRedirect('/rateables/' + str(entity_id))
return HttpResponseBadRequest("Bad Request")