An actual minimum viable product, maybe? #11

Merged
andrewlalis merged 43 commits from develop into master 2018-10-12 18:19:41 +00:00
4 changed files with 46 additions and 21 deletions
Showing only changes of commit e2830fb32d - Show all commits

Binary file not shown.

View File

@ -1,4 +1,4 @@
# Generated by Django 2.1.1 on 2018-09-27 09:48
# Generated by Django 2.1.1 on 2018-10-02 13:24
from django.db import migrations, models
import django.db.models.deletion
@ -17,6 +17,8 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=256)),
('created_date', models.DateTimeField(auto_now_add=True)),
('entity_type', models.SmallIntegerField(choices=[(0, 'University'), (1, 'Course'), (2, 'Professor')])),
],
),
migrations.CreateModel(
@ -46,10 +48,18 @@ class Migration(migrations.Migration):
('username', models.CharField(max_length=200)),
('rating', models.IntegerField(default=1)),
('title', models.CharField(max_length=200)),
('date_published', models.DateField(verbose_name='date published')),
('date_published', models.DateTimeField(auto_now_add=True)),
('content', models.CharField(max_length=200)),
],
),
migrations.CreateModel(
name='User',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=64)),
('birth_date', models.DateField()),
],
),
migrations.CreateModel(
name='Course',
fields=[
@ -68,9 +78,16 @@ class Migration(migrations.Migration):
name='University',
fields=[
('rateableentity_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='postings.RateableEntity')),
('website_url', models.URLField()),
('location', models.CharField(max_length=256)),
],
bases=('postings.rateableentity',),
),
migrations.AddField(
model_name='review',
name='author',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='postings.User'),
),
migrations.AddField(
model_name='review',
name='rateable_entity',

View File

@ -1,18 +0,0 @@
# Generated by Django 2.1.1 on 2018-09-27 11:15
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('postings', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='universityreview',
name='date_published',
field=models.DateTimeField(auto_now_add=True),
),
]

View File

@ -1,9 +1,30 @@
from django.db import models
# Represents an authenticated reviewer or reader of reviews.
class User(models.Model):
# A non-unique name for the user.
name = models.CharField(max_length=64)
# The user's birth date.
birth_date = models.DateField()
# Represents any object for which reviews can be made. (Universities, Professors, etc.)
class RateableEntity(models.Model):
# Constants defined for types of rateable entities.
UNIVERSITY = 0
COURSE = 1
PROFESSOR = 2
TYPE_CHOICES = (
(UNIVERSITY, 'University'),
(COURSE, 'Course'),
(PROFESSOR, 'Professor')
)
# The human-readable name of this entity.
name = models.CharField(max_length=256)
# The date and time at which this entity was created.
created_date = models.DateTimeField(auto_now_add=True)
# The type of entity this is.
entity_type = models.SmallIntegerField(choices=TYPE_CHOICES)
# A review represents any single data entry to the database.
class Review(models.Model):
@ -19,6 +40,8 @@ class Review(models.Model):
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 reference to the person who created this review.
author = models.ForeignKey('postings.User', on_delete=models.PROTECT)
# A vote for a review as either positive or negative.
class ReviewHelpfulVote(models.Model):
@ -30,7 +53,10 @@ class ReviewHelpfulVote(models.Model):
# A RateableEntity for universities.
class University(RateableEntity):
pass
# A string referring to the URL of the university. Every single university should have one.
website_url = models.URLField()
# A string referring to the location of the university.
location = models.CharField(max_length=256)
# A RateableEntity for professors, who belong to one or more university.
class Professor(RateableEntity):