An actual minimum viable product, maybe? #11

Merged
andrewlalis merged 43 commits from develop into master 2018-10-12 18:19:41 +00:00
3 changed files with 9 additions and 8 deletions
Showing only changes of commit a8597b1ce4 - Show all commits

Binary file not shown.

View File

@ -1,4 +1,7 @@
{# Template for displaying one review. #} {# 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> <p>{{ review.content }}</p>

View File

@ -59,7 +59,10 @@ def post_review(request):
title = form.cleaned_data['title'] title = form.cleaned_data['title']
content = form.cleaned_data['content'] content = form.cleaned_data['content']
entity_id = form.cleaned_data['entity_id'] entity_id = form.cleaned_data['entity_id']
entity = RateableEntity.objects.get(pk=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. # Creates the new Review object from the posted data.
review = Review.objects.create( review = Review.objects.create(
@ -70,11 +73,6 @@ def post_review(request):
) )
# Send the user back to the entity they were viewing. # Send the user back to the entity they were viewing.
redirect_path = '/' return HttpResponseRedirect('/rateables/' + str(entity_id))
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 HttpResponseBadRequest("Bad Request") return HttpResponseBadRequest("Bad Request")