Refactored directories and cleaned things up #10

Merged
andrewlalis merged 2 commits from al/directory_refactor into develop 2018-10-03 21:10:03 +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. #}
<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")