From a8597b1ce425964e8e0ac9a3a36439e228220b56 Mon Sep 17 00:00:00 2001 From: andrewlalis Date: Wed, 3 Oct 2018 23:08:57 +0200 Subject: [PATCH] Added date display to review html. --- backend/db.sqlite3 | Bin 77824 -> 77824 bytes .../templates/postings/rateables/review.html | 5 ++++- backend/postings/views.py | 12 +++++------- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/backend/db.sqlite3 b/backend/db.sqlite3 index ef66ed954b5bca41d0b26e7fed3a786748c63b36..e6ee6dc39ee4fd2bed65d254cf5f6a73cc64540a 100644 GIT binary patch delta 594 zcmchSu}%U(5QcA^GvUC-#zu|P5fdQ?9EeyE3q!#(;K422hLtmS3rH*gV?(EJVQVgi zSosJP#KeSNLMP`- z8VnS8hc|eEJ9vN_7{C*Z{6+N=7UqEv&^~LxANAK&=^iTZEFF(<4`aB6p}c*S?kfnY zpb%|Z0{-|qYz2Yz6v)q2Nl)rWq}?rOL4|A|uV%AEfh>1f#TFY_tP6A+)ID%niCQ`2 zOiWWnoa25AIV}sUGOI>g({+UkWHs3cn|bJ!Y{%hWX-tGYY&x#6kqIo) zl3DjCwrfrkbJ%3lG_y+4V~1E~mAXqk86-!}N=^+M@;7Zo<9aL|iRlqNf$>;IPh<=| vn%dG0!RY^4yH{{ review.title }} {{ review.rating }} +

{{ review.title }}

+Rating: {{ review.rating }}
+Posted on {{ review.created_date|date:"j M, Y" }}
+

{{ review.content }}

\ No newline at end of file diff --git a/backend/postings/views.py b/backend/postings/views.py index 481b24a..1f65c22 100644 --- a/backend/postings/views.py +++ b/backend/postings/views.py @@ -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'] - 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. 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") \ No newline at end of file