Al/small updates #18

Merged
andrewlalis merged 12 commits from al/small_updates into develop 2018-10-18 11:13:50 +00:00
3 changed files with 10 additions and 2 deletions
Showing only changes of commit b666a13562 - Show all commits

Binary file not shown.

View File

@ -10,3 +10,5 @@ class EntityReviewForm(forms.Form):
content = forms.CharField(widget=forms.Textarea) content = forms.CharField(widget=forms.Textarea)
# The id of the entity for which the review is created. # The id of the entity for which the review is created.
entity_id = forms.IntegerField() entity_id = forms.IntegerField()
# TEMPORARY name for author name.
name = forms.CharField(max_length=64, required=False)

View File

@ -71,10 +71,15 @@ def post_review(request):
if form.is_valid(): if form.is_valid():
# Only if the request is a POST and the form is valid do we do anything. # Only if the request is a POST and the form is valid do we do anything.
rating = form.cleaned_data['rating'] rating = form.cleaned_data['rating']
name = form.cleaned_data['name']
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']
if 'name' in request.POST:
author_name = form.cleaned_data['name']
else:
author_name = None
try: try:
entity = RateableEntity.objects.get(pk=entity_id) entity = RateableEntity.objects.get(pk=entity_id)
except RateableEntity.DoesNotExist: except RateableEntity.DoesNotExist:
@ -83,6 +88,7 @@ def post_review(request):
# 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(
rating=rating, rating=rating,
author_name=author_name,
title=title, title=title,
content=content, content=content,
rateable_entity=entity rateable_entity=entity