introduce story round and participants, extend models with additional information, replace initial migration
No need for backwards compatibility at this point, so just replace the migration
This commit is contained in:
parent
03aee0abd6
commit
8aa459d2ef
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 3.1.7 on 2021-03-30 19:23
|
||||
# Generated by Django 3.1.7 on 2021-03-30 23:08
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
@ -14,12 +14,29 @@ class Migration(migrations.Migration):
|
|||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Participant',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('order_by', models.IntegerField()),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Story',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(blank=True, max_length=256, null=True)),
|
||||
('created', models.DateTimeField()),
|
||||
('created', models.DateTimeField(auto_now_add=True)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='StoryRound',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=256)),
|
||||
('created', models.DateTimeField(auto_now_add=True)),
|
||||
('number_of_rounds', models.IntegerField()),
|
||||
('participants', models.ManyToManyField(through='writingtogether.Participant', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
|
@ -28,7 +45,28 @@ class Migration(migrations.Migration):
|
|||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('text', models.TextField()),
|
||||
('part_of', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='writingtogether.story')),
|
||||
('previous_part', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='writingtogether.storypart')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='story',
|
||||
name='part_of_round',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='writingtogether.storyround'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='story',
|
||||
name='started_by',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='participant',
|
||||
name='story_round',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='writingtogether.storyround'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='participant',
|
||||
name='user',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -1,15 +1,36 @@
|
|||
from django.contrib.auth import get_user_model
|
||||
from django.db import models
|
||||
from django.db.models import CASCADE
|
||||
from django.urls import reverse
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
class StoryRound(models.Model):
|
||||
name = models.CharField(max_length=256)
|
||||
participants = models.ManyToManyField(User, through='Participant')
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
number_of_rounds = models.IntegerField()
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('writing:detail', kwargs={'pk': self.pk})
|
||||
|
||||
|
||||
class Participant(models.Model):
|
||||
user = models.ForeignKey(User, on_delete=CASCADE)
|
||||
story_round = models.ForeignKey(StoryRound, on_delete=CASCADE)
|
||||
order_by = models.IntegerField()
|
||||
|
||||
|
||||
class Story(models.Model):
|
||||
name = models.CharField(max_length=256, null=True, blank=True)
|
||||
created = models.DateTimeField()
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
part_of_round = models.ForeignKey(StoryRound, on_delete=CASCADE)
|
||||
started_by = models.ForeignKey(User, on_delete=CASCADE)
|
||||
|
||||
|
||||
class StoryPart(models.Model):
|
||||
user = models.ForeignKey(User, on_delete=CASCADE)
|
||||
previous_part = models.ForeignKey('StoryPart', on_delete=CASCADE, null=True, blank=True)
|
||||
text = models.TextField()
|
||||
part_of = models.ForeignKey('Story', on_delete=CASCADE)
|
||||
part_of = models.ForeignKey('Story', on_delete=CASCADE)
|
||||
|
|
Loading…
Reference in New Issue