From 041837fd7a9923c338939895e1f558f170293985 Mon Sep 17 00:00:00 2001 From: Bo Lopker Date: Sun, 11 Aug 2024 12:50:55 +1200 Subject: [PATCH] Set ordering and unique_together on events --- ...0039_alter_circleevent_options_and_more.py | 21 +++++++++++++++++++ totem/circles/models.py | 4 ++++ 2 files changed, 25 insertions(+) create mode 100644 totem/circles/migrations/0039_alter_circleevent_options_and_more.py diff --git a/totem/circles/migrations/0039_alter_circleevent_options_and_more.py b/totem/circles/migrations/0039_alter_circleevent_options_and_more.py new file mode 100644 index 00000000..fafcaac4 --- /dev/null +++ b/totem/circles/migrations/0039_alter_circleevent_options_and_more.py @@ -0,0 +1,21 @@ +# Generated by Django 5.0.8 on 2024-08-11 00:43 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('circles', '0038_alter_circlecategory_options_alter_circle_image_and_more'), + ] + + operations = [ + migrations.AlterModelOptions( + name='circleevent', + options={'ordering': ['start']}, + ), + migrations.AlterUniqueTogether( + name='circleevent', + unique_together={('circle', 'start', 'open')}, + ), + ] diff --git a/totem/circles/models.py b/totem/circles/models.py index 14a5148d..970b3ee5 100644 --- a/totem/circles/models.py +++ b/totem/circles/models.py @@ -158,6 +158,10 @@ class CircleEvent(AdminURLMixin, MarkdownMixin, SluggedModel): seats = models.IntegerField(default=8) start = models.DateTimeField(default=timezone.now) + class Meta: + ordering = ["start"] + unique_together = [["circle", "start", "open"]] + def get_absolute_url(self) -> str: return reverse("circles:event_detail", kwargs={"event_slug": self.slug})