diff --git a/members/admin/activity_admin.py b/members/admin/activity_admin.py index d7d5279e..7e3b1798 100644 --- a/members/admin/activity_admin.py +++ b/members/admin/activity_admin.py @@ -276,6 +276,8 @@ def formfield_for_foreignkey(self, db_field, request, **kwargs): "end_date", ), "member_justified", + "visible", + "visible_from", ), }, ), diff --git a/members/migrations/0053_activity_visible_activity_visible_from.py b/members/migrations/0053_activity_visible_activity_visible_from.py new file mode 100644 index 00000000..5989d0f5 --- /dev/null +++ b/members/migrations/0053_activity_visible_activity_visible_from.py @@ -0,0 +1,31 @@ +# Generated by Django 4.2.11 on 2024-06-17 19:46 + +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + ("members", "0052_alter_activity_address"), + ] + + operations = [ + migrations.AddField( + model_name="activity", + name="visible", + field=models.BooleanField( + default=True, + help_text="Vises i denne aktivtet. Kan bruges sammen med feltet 'Aktiviteten er synlig fra'", + verbose_name="Vises denne aktivitet", + ), + ), + migrations.AddField( + model_name="activity", + name="visible_from", + field=models.DateTimeField( + default=django.utils.timezone.now, + verbose_name="Aktiviteten er synlig fra", + ), + ), + ] diff --git a/members/migrations/0054_merge_20240617_2150.py b/members/migrations/0054_merge_20240617_2150.py new file mode 100644 index 00000000..cfee731d --- /dev/null +++ b/members/migrations/0054_merge_20240617_2150.py @@ -0,0 +1,13 @@ +# Generated by Django 4.2.11 on 2024-06-17 19:50 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("members", "0053_activity_visible_activity_visible_from"), + ("members", "0053_alter_emailitem_options"), + ] + + operations = [] diff --git a/members/models/activity.py b/members/models/activity.py index 0f5a8b98..876f75a5 100644 --- a/members/models/activity.py +++ b/members/models/activity.py @@ -74,6 +74,16 @@ class Meta: address = models.ForeignKey( "Address", on_delete=models.PROTECT, verbose_name="Adresse", null=False ) + visible_from = models.DateTimeField( + "Aktiviteten er synlig fra", null=False, blank=False, default=timezone.now + ) + visible = models.BooleanField( + "Vises denne aktivitet", + null=False, + blank=False, + default=True, + help_text="Vises i denne aktivtet. Kan bruges sammen med feltet 'Aktiviteten er synlig fra'", + ) def is_historic(self): return self.end_date < timezone.now() diff --git a/members/views/Activities.py b/members/views/Activities.py index 97cdd171..72f47198 100644 --- a/members/views/Activities.py +++ b/members/views/Activities.py @@ -19,6 +19,8 @@ def Activities(request): signup_closing__gte=timezone.now(), end_date__gte=timezone.now(), activitytype__in=["FORLØB", "ARRANGEMENT"], + visible=True, + visible_from__lte=timezone.now(), ).order_by("address__region", "name", "start_date") family = None