diff --git a/core/migrations/0016_auto_20210924_1351.py b/core/migrations/0016_auto_20210924_1351.py new file mode 100644 index 0000000..919bd9a --- /dev/null +++ b/core/migrations/0016_auto_20210924_1351.py @@ -0,0 +1,42 @@ +# Generated by Django 3.1.1 on 2021-09-24 17:51 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0015_profile_is_hidden'), + ] + + operations = [ + migrations.CreateModel( + name='PollChoice', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('text', models.CharField(max_length=300)), + ('votes', models.IntegerField(default=0)), + ], + ), + migrations.CreateModel( + name='PollQuestion', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('text', models.CharField(max_length=300)), + ], + ), + migrations.DeleteModel( + name='Poll', + ), + migrations.AddField( + model_name='pollchoice', + name='question', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='choices', to='core.pollquestion'), + ), + migrations.AddField( + model_name='content', + name='polls', + field=models.ManyToManyField(blank=True, related_name='stories', to='core.PollQuestion'), + ), + ] diff --git a/core/models.py b/core/models.py index dae59af..83ed4db 100755 --- a/core/models.py +++ b/core/models.py @@ -105,6 +105,18 @@ def __str__(self): return self.name +class PollQuestion(models.Model): + text = models.CharField(max_length=300) + + +class PollChoice(models.Model): + question = models.ForeignKey( + PollQuestion, on_delete=models.CASCADE, related_name="choices" + ) + text = models.CharField(max_length=300) + votes = models.IntegerField(default=0) + + class Content(PolymorphicModel): """A generic content model. @@ -142,6 +154,9 @@ class Content(PolymorphicModel): on_delete=models.SET_NULL, ) views = models.IntegerField(default=0) + polls = models.ManyToManyField( + PollQuestion, related_name="stories", blank=True + ) # Whether this content should show up by itself embed_only = models.BooleanField( @@ -345,10 +360,6 @@ class Audio(Content): descriptor = "Audio" -class Poll(Content): - pass # STUB_POLL - - class Story(Content): """The main story model.""" diff --git a/home/templates/home/content.html b/home/templates/home/content.html index 0e5eb81..d08c2f8 100644 --- a/home/templates/home/content.html +++ b/home/templates/home/content.html @@ -137,6 +137,10 @@