make things easier by adding turn numbers
This commit is contained in:
parent
368653b88a
commit
d0b2d9c484
|
@ -0,0 +1,24 @@
|
|||
# Generated by Django 3.1.7 on 2021-04-19 22:24
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('writingtogether', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='storypart',
|
||||
name='turn_number',
|
||||
field=models.IntegerField(default=0),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='storyround',
|
||||
name='current_turn',
|
||||
field=models.IntegerField(blank=True, default=0),
|
||||
),
|
||||
]
|
|
@ -11,6 +11,7 @@ class StoryRound(models.Model):
|
|||
participants = models.ManyToManyField(User) # for ordering add: through='Participant'
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
number_of_rounds = models.IntegerField()
|
||||
current_turn = models.IntegerField(default=0, blank=True)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('writing:detail', kwargs={'pk': self.pk})
|
||||
|
@ -51,6 +52,7 @@ class StoryPart(models.Model):
|
|||
previous_part = models.ForeignKey('StoryPart', on_delete=CASCADE, null=True, blank=True)
|
||||
text = models.TextField(null=True, blank=True)
|
||||
part_of = models.ForeignKey('Story', on_delete=CASCADE)
|
||||
turn_number = models.IntegerField()
|
||||
|
||||
@property
|
||||
def finished(self):
|
||||
|
|
|
@ -47,7 +47,8 @@ class TestModelFunctions(TestCase):
|
|||
new_part = StoryPart.objects.create(
|
||||
user=user,
|
||||
previous_part=previous_part,
|
||||
part_of=story
|
||||
part_of=story,
|
||||
round_number=i
|
||||
)
|
||||
parts.append(new_part)
|
||||
previous_part = new_part
|
||||
|
|
Loading…
Reference in New Issue