2018-09-16 16:52:23 +00:00
|
|
|
from django.db import models
|
|
|
|
|
2018-09-25 13:40:58 +00:00
|
|
|
# Represents any object for which reviews can be made. (Universities, Professors, etc.)
|
|
|
|
class RateableEntity(models.Model):
|
|
|
|
# The human-readable name of this entity.
|
|
|
|
name = models.CharField(max_length=256)
|
|
|
|
|
|
|
|
# A review represents any single data entry to the database.
|
2018-09-25 12:13:25 +00:00
|
|
|
class Review(models.Model):
|
2018-09-25 13:40:58 +00:00
|
|
|
# An integer rating in the domain [1, 5]
|
2018-09-25 12:13:25 +00:00
|
|
|
rating = models.IntegerField(default=1)
|
2018-09-25 15:09:39 +00:00
|
|
|
# A title for the review (brief summary of sentiment)
|
|
|
|
title = models.CharField(max_length=128)
|
2018-09-25 13:40:58 +00:00
|
|
|
# The textual content of the review.
|
|
|
|
content = models.TextField()
|
|
|
|
# A foreign key referencing the entity for which this review was made.
|
2018-09-25 15:09:39 +00:00
|
|
|
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.
|
2018-09-25 13:40:58 +00:00
|
|
|
|
|
|
|
# A RateableEntity for universities.
|
|
|
|
class University(RateableEntity):
|
|
|
|
pass
|
|
|
|
|
|
|
|
# A RateableEntity for professors, who belong to one or more university.
|
|
|
|
class Professor(RateableEntity):
|
|
|
|
# The universities that this professor teaches or has taught at.
|
2018-09-25 14:47:01 +00:00
|
|
|
university = models.ManyToManyField('postings.University')
|
2018-09-25 13:40:58 +00:00
|
|
|
|
|
|
|
# A RateableEntity for courses, which belong to a university, and have one or more professors.
|
|
|
|
class Course(RateableEntity):
|
|
|
|
# The university that this course belongs to.
|
2018-09-25 14:47:01 +00:00
|
|
|
taught_at_university = models.ForeignKey('postings.University', on_delete=models.CASCADE)
|
2018-09-25 13:40:58 +00:00
|
|
|
# A list of professors that teach this course.
|
2018-09-25 14:47:01 +00:00
|
|
|
professors = models.ManyToManyField('postings.Professor')
|
2018-09-25 12:13:25 +00:00
|
|
|
|
2018-09-16 16:52:23 +00:00
|
|
|
# Create your models here.
|
|
|
|
class UniversityReview(models.Model):
|
|
|
|
university_name = models.CharField(max_length=200)
|
|
|
|
username = models.CharField(max_length=200)
|
2018-09-26 11:14:02 +00:00
|
|
|
rating = models.IntegerField(default=1)
|
2018-09-16 16:52:23 +00:00
|
|
|
title = models.CharField(max_length=200)
|
2018-09-27 07:24:51 +00:00
|
|
|
date_published = models.DateField('date published')
|
2018-09-16 16:52:23 +00:00
|
|
|
content = models.CharField(max_length=200)
|
|
|
|
|