Added temporary user name shortcut for now.

This commit is contained in:
Andrew Lalis 2018-10-18 10:32:37 +02:00
parent 176658c319
commit 643e9ea1d3
6 changed files with 24 additions and 3 deletions

Binary file not shown.

View File

@ -0,0 +1,18 @@
# Generated by Django 2.1.1 on 2018-10-18 08:30
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('postings', '0004_remove_reviewhelpfulvote_user'),
]
operations = [
migrations.AddField(
model_name='review',
name='author_name',
field=models.CharField(default='Anonymous', max_length=64),
),
]

View File

@ -74,6 +74,8 @@ class Review(models.Model):
last_updated_date = models.DateTimeField(auto_now=True) last_updated_date = models.DateTimeField(auto_now=True)
# A reference to the person who created this review. # A reference to the person who created this review.
author = models.ForeignKey('postings.User', on_delete=models.PROTECT, null=True, blank=True) author = models.ForeignKey('postings.User', on_delete=models.PROTECT, null=True, blank=True)
# TEMPORARY: Name of person who gave review.
author_name = models.CharField(max_length=64, default='Anonymous')
# Gets the total number of votes which marked this review as 'helpful'. # Gets the total number of votes which marked this review as 'helpful'.
@property @property

View File

@ -55,8 +55,8 @@
{# Username input #} {# Username input #}
<div class="form-group"> <div class="form-group">
<label for="name_input">Name:</label> <label for="name_input">Name (Optional):</label>
<input type="text" class="form-control" placeholder="Name..." id="name_input"> <input type="text" class="form-control" placeholder="Name..." id="name_input" name="name">
</div> </div>
{# Title input #} {# Title input #}

View File

@ -7,7 +7,7 @@
<span class="big-font glyphicon glyphicon-user img-rounded"></span> <span class="big-font glyphicon glyphicon-user img-rounded"></span>
{# Username #} {# Username #}
<div class="review-block-name"><a href="#">Student</a></div> <div class="review-block-name"><a href="#">{{ review.author_name }}</a></div>
{# Date at which review was posted. #} {# Date at which review was posted. #}
<div class="review-block-date">{{ review.created_date|date:"j M, Y" }}<br/></div> <div class="review-block-date">{{ review.created_date|date:"j M, Y" }}<br/></div>

View File

@ -71,6 +71,7 @@ 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']