From ad312a6e7680c0a909ac62b174229a5d0895edc1 Mon Sep 17 00:00:00 2001 From: andrewlalis Date: Tue, 25 Sep 2018 17:09:39 +0200 Subject: [PATCH] Updated models to be more robust. --- backend/postings/models.py | 20 +++++++++++++++----- frontpage/index2.html | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/backend/postings/models.py b/backend/postings/models.py index d7a0514..bc1038a 100644 --- a/backend/postings/models.py +++ b/backend/postings/models.py @@ -9,14 +9,24 @@ class RateableEntity(models.Model): class Review(models.Model): # An integer rating in the domain [1, 5] rating = models.IntegerField(default=1) + # A title for the review (brief summary of sentiment) + title = models.CharField(max_length=128) # The textual content of the review. content = models.TextField() - # An integer representing the number of times a user found this review helpful. - helpful_vote_count = models.IntegerField(default=1) - # An integer representing the number of times a user found this review unhelpful. - unhelpful_vote_count = models.IntegerField(default=1) # A foreign key referencing the entity for which this review was made. - rateable_entity_id = models.ForeignKey('postings.RateableEntity', on_delete=models.CASCADE) + rateable_entity = models.ForeignKey('postings.RateableEntity', on_delete=models.CASCADE) + # The date and time at which this review was published. + created_date = models.DateTimeField(auto_now_add=True) + # The date and time at which the last modification to this review was published. + last_updated_date = models.DateTimeField(auto_now=True) + +# A vote for a review as either positive or negative. +class ReviewHelpfulVote(models.Model): + # A reference to the review that this vote is for. + review = models.ForeignKey('postings.Review', on_delete=models.CASCADE) + # Whether or not the referenced review was helpful. + helpful = models.BooleanField() + # TODO: Add a reference to the user who voted. The whole purpose of a separate vote object is to track who votes for what. # A RateableEntity for universities. class University(RateableEntity): diff --git a/frontpage/index2.html b/frontpage/index2.html index 2c47647..9c25473 100644 --- a/frontpage/index2.html +++ b/frontpage/index2.html @@ -184,7 +184,7 @@