From c79432567c3bf67ca91a4b1638d54de7a0375f97 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Wed, 13 Jan 2021 13:26:57 +0100 Subject: [PATCH] valid_until migration fix --- .../migrations/0098_auto_20210113_1320.py | 19 +++++++++++++++++++ cookbook/models.py | 6 +++++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 cookbook/migrations/0098_auto_20210113_1320.py diff --git a/cookbook/migrations/0098_auto_20210113_1320.py b/cookbook/migrations/0098_auto_20210113_1320.py new file mode 100644 index 000000000..8c50601ff --- /dev/null +++ b/cookbook/migrations/0098_auto_20210113_1320.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1.5 on 2021-01-13 12:20 + +import cookbook.models +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cookbook', '0097_auto_20210113_1315'), + ] + + operations = [ + migrations.AlterField( + model_name='invitelink', + name='valid_until', + field=models.DateField(default=cookbook.models.default_valid_until), + ), + ] diff --git a/cookbook/models.py b/cookbook/models.py index 4387d3ad1..3c9763303 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -421,11 +421,15 @@ class ShareLink(models.Model): return f'{self.recipe} - {self.uuid}' +def default_valid_until(): + return date.today() + timedelta(days=14) + + class InviteLink(models.Model): uuid = models.UUIDField(default=uuid.uuid4) username = models.CharField(blank=True, max_length=64) group = models.ForeignKey(Group, on_delete=models.CASCADE) - valid_until = models.DateField(default=date.today() + timedelta(days=14)) + valid_until = models.DateField(default=default_valid_until) used_by = models.ForeignKey( User, null=True, on_delete=models.CASCADE, related_name='used_by' )