From 69e33593c3d81f9f3512bf3fc1f7fe206ed931a1 Mon Sep 17 00:00:00 2001
From: George Katsikas <giorgakis.katsikas@gmail.com>
Date: Mon, 7 Oct 2024 15:36:53 +0200
Subject: [PATCH] add is_active boolean for collections

---
 .../migrations/0010_collection_is_active.py     | 17 +++++++++++++++++
 scipost_django/series/models.py                 |  1 +
 scipost_django/submissions/forms/__init__.py    |  1 +
 3 files changed, 19 insertions(+)
 create mode 100644 scipost_django/series/migrations/0010_collection_is_active.py

diff --git a/scipost_django/series/migrations/0010_collection_is_active.py b/scipost_django/series/migrations/0010_collection_is_active.py
new file mode 100644
index 000000000..07c0cb4a1
--- /dev/null
+++ b/scipost_django/series/migrations/0010_collection_is_active.py
@@ -0,0 +1,17 @@
+# Generated by Django 4.2.15 on 2024-10-07 13:35
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+    dependencies = [
+        ("series", "0009_collection_event_details"),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name="collection",
+            name="is_active",
+            field=models.BooleanField(default=True),
+        ),
+    ]
diff --git a/scipost_django/series/models.py b/scipost_django/series/models.py
index dd0c2e20a..e22d37067 100644
--- a/scipost_django/series/models.py
+++ b/scipost_django/series/models.py
@@ -72,6 +72,7 @@ class Collection(models.Model):
         ),
     )
     image = models.ImageField(upload_to="series/collections/images/", blank=True)
+    is_active = models.BooleanField(default=True)
 
     expected_authors = models.ManyToManyField(
         "profiles.Profile", blank=True, related_name="collections_authoring"
diff --git a/scipost_django/submissions/forms/__init__.py b/scipost_django/submissions/forms/__init__.py
index fd3831e7a..8bc682eb9 100644
--- a/scipost_django/submissions/forms/__init__.py
+++ b/scipost_django/submissions/forms/__init__.py
@@ -1297,6 +1297,7 @@ class SubmissionForm(forms.ModelForm):
         choices=[(None, "None")]
         + list(
             Collection.objects.all()
+            .filter(is_active=True)
             .order_by("-event_start_date")
             # Short name is `event_suffix` if set, otherwise `event_name`
             .annotate(name_with_series=Concat("series__name", Value(" - "), "name"))
-- 
GitLab