From aff615c3e5c4cc12b1cbf4c0a8202681c2fc278d Mon Sep 17 00:00:00 2001 From: andrewlalis Date: Tue, 2 Oct 2018 15:24:59 +0200 Subject: [PATCH] Compiled migrations into just first migration. --- backend/db.sqlite3 | Bin 71680 -> 72704 bytes backend/postings/migrations/0001_initial.py | 21 +++++++++++-- .../migrations/0002_auto_20180927_1115.py | 18 ----------- backend/postings/models.py | 28 +++++++++++++++++- 4 files changed, 46 insertions(+), 21 deletions(-) delete mode 100644 backend/postings/migrations/0002_auto_20180927_1115.py diff --git a/backend/db.sqlite3 b/backend/db.sqlite3 index 359edf330bb4fdc20cdd32a017fd03ced1c164be..232a12ee572ac15d3ed89ffc49a0d6fdbbc3551b 100644 GIT binary patch delta 1646 zcmZ8hdrVVT7(d_nZfOhc)mFMIg+k>qh4ScQr3EIgx}kGUVIaQ7YK0E!c(>}@mQ5fr z`$HpmP!@In7?-Im8*()m9U2p(fYE72VbdAS+%kqP)3_{4Hp5PfbHi}7##6Yt?K_#-~RoA@1G z!C^d)-{M(3CF=wmn%!Q`b5?P%S8~X!;4rt0L*^O|&o7m4Vycj+)?xxt(MJT+a1u9S z7<;e-3+W^Jh`YH%6~>uZq+;_gNdm4Wv8*UADaMc_;sO=B8kblC)$DI= z2n2(HrbaiLj58*SbeLc$rYI1T;c0XEx<1Q>ZhC?# zUk<3~MS6~&rYAUiKAo*V0MQ*qR}}N3=#(#)H~?a0STeO3v@-mp5H#I{R?s<62Nu%J zbV9p){MVhpuIzEhsoh^dyq33sQazy)R1aD7HWxqb@+7m5CzE)r^MGyTr7UN^6|!09 zgv1ihq_I!-*TuFQURO#U4|F)$)x+_usyB{R?KMJ1l(cK_;K2jJ?x6u#!%hyZhkVvK zE-~w{U%gr-wV7Un_HuT1$j+_~7eW^63!B)QF^Mf0X@OPj*hm(<5cQHf7{hu8jXYef z{NAPQ!oe3+{MBo5E!4XbD)Oq3$0ogL1a8w;X0YmScE| z$?RHh9(JhSV8e&AAop>qF>GMMDVH1(0lw$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z+CO8LgkdMWRDx6K<@DQJJ?N?M{hPXg&7o1Mt06G%?|tEA?`%mn zC~<&P;ompglMUTEvsPqt-p}^F7h7d)6h0x5 zfI8uDVxXv&io+f#rgIw#O^4f|hPJ~UkRP`vmi6@fazm&_l2z%ehzu_J;c7kD=vL53 zYimiW>zn;Crry&mRRxoWi=`O?1mjz}OGv?W?G6E z>A7`OP;3BzEql}9Z38F+kjjoqL*@NR5|Lak=1)BYT6$q^fA9*3s2kEu#7I2CNa%g7TMAA>Cn%J0ASQlyTJgx5TdO`j2cMp#p zB6cycax>T^W`78Iou1TPbDFiPsI7`SgCkb_$!&^f6Iiv|S1fK~E{sZ;sVz~eS 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):