diff --git a/backend/db.sqlite3 b/backend/db.sqlite3 index 359edf3..232a12e 100644 Binary files a/backend/db.sqlite3 and b/backend/db.sqlite3 differ diff --git a/backend/postings/migrations/0001_initial.py b/backend/postings/migrations/0001_initial.py index f7cab3a..ce37acb 100644 --- a/backend/postings/migrations/0001_initial.py +++ b/backend/postings/migrations/0001_initial.py @@ -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', diff --git a/backend/postings/migrations/0002_auto_20180927_1115.py b/backend/postings/migrations/0002_auto_20180927_1115.py deleted file mode 100644 index 68acb33..0000000 --- a/backend/postings/migrations/0002_auto_20180927_1115.py +++ /dev/null @@ -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), - ), - ] diff --git a/backend/postings/models.py b/backend/postings/models.py index f6cf652..70049a5 100644 --- a/backend/postings/models.py +++ b/backend/postings/models.py @@ -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):