From ec64ef0ab5bb67ef9c0b7e603bb7f23d05a01b31 Mon Sep 17 00:00:00 2001 From: mhewel <58829786+mhewel@users.noreply.github.com> Date: Sat, 1 Jun 2024 09:54:05 +0200 Subject: [PATCH 1/5] Nye felt for Aktiviteter : visible_from MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Default er timezone.now(), så nye aktiviteter per default er synlige når de er lavet (og såfremt de andre værdier er OK, f.x. at aktiviteten ender i fremtiden etc.). --- members/admin/activity_admin.py | 1 + .../migrations/0053_activity_visible_from.py | 22 +++++++++++++++++++ members/models/activity.py | 3 +++ members/views/Activities.py | 1 + 4 files changed, 27 insertions(+) create mode 100644 members/migrations/0053_activity_visible_from.py diff --git a/members/admin/activity_admin.py b/members/admin/activity_admin.py index d7d5279e..8142090f 100644 --- a/members/admin/activity_admin.py +++ b/members/admin/activity_admin.py @@ -276,6 +276,7 @@ def formfield_for_foreignkey(self, db_field, request, **kwargs): "end_date", ), "member_justified", + "visible_from", ), }, ), diff --git a/members/migrations/0053_activity_visible_from.py b/members/migrations/0053_activity_visible_from.py new file mode 100644 index 00000000..b2e9491c --- /dev/null +++ b/members/migrations/0053_activity_visible_from.py @@ -0,0 +1,22 @@ +# Generated by Django 4.2.11 on 2024-06-01 07:45 + +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_from", + field=models.DateTimeField( + default=django.utils.timezone.now, + verbose_name="Aktiviteten er synlig fra", + ), + ), + ] diff --git a/members/models/activity.py b/members/models/activity.py index 56ebd14e..484b7668 100644 --- a/members/models/activity.py +++ b/members/models/activity.py @@ -74,6 +74,9 @@ 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 + ) def is_historic(self): return self.end_date < timezone.now() diff --git a/members/views/Activities.py b/members/views/Activities.py index 97cdd171..ff82b201 100644 --- a/members/views/Activities.py +++ b/members/views/Activities.py @@ -19,6 +19,7 @@ def Activities(request): signup_closing__gte=timezone.now(), end_date__gte=timezone.now(), activitytype__in=["FORLØB", "ARRANGEMENT"], + visible_from__lte=timezone.now(), ).order_by("address__region", "name", "start_date") family = None From 5855c7d423be4bd63e31c1f63a97d55d82499fb2 Mon Sep 17 00:00:00 2001 From: mhewel <58829786+mhewel@users.noreply.github.com> Date: Mon, 17 Jun 2024 21:29:40 +0200 Subject: [PATCH 2/5] =?UTF-8?q?Tilf=C3=B8jede=20nyt=20felt=20:=20Visible?= =?UTF-8?q?=20for=20en=20aktivitet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- members/admin/activity_admin.py | 1 + members/migrations/0054_activity_visible.py | 22 +++++++++++++++++++++ members/models/activity.py | 4 ++++ members/views/Activities.py | 1 + 4 files changed, 28 insertions(+) create mode 100644 members/migrations/0054_activity_visible.py diff --git a/members/admin/activity_admin.py b/members/admin/activity_admin.py index 8142090f..7e3b1798 100644 --- a/members/admin/activity_admin.py +++ b/members/admin/activity_admin.py @@ -276,6 +276,7 @@ def formfield_for_foreignkey(self, db_field, request, **kwargs): "end_date", ), "member_justified", + "visible", "visible_from", ), }, diff --git a/members/migrations/0054_activity_visible.py b/members/migrations/0054_activity_visible.py new file mode 100644 index 00000000..5fb33005 --- /dev/null +++ b/members/migrations/0054_activity_visible.py @@ -0,0 +1,22 @@ +# Generated by Django 4.2.11 on 2024-06-17 19:24 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("members", "0053_activity_visible_from"), + ] + + 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", + ), + ), + ] diff --git a/members/models/activity.py b/members/models/activity.py index 484b7668..2d25e9e3 100644 --- a/members/models/activity.py +++ b/members/models/activity.py @@ -77,6 +77,10 @@ class Meta: 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 ff82b201..72f47198 100644 --- a/members/views/Activities.py +++ b/members/views/Activities.py @@ -19,6 +19,7 @@ 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") From b42303299a5c16f86e72e5cb1079dd7f9601852a Mon Sep 17 00:00:00 2001 From: mhewel <58829786+mhewel@users.noreply.github.com> Date: Mon, 17 Jun 2024 21:38:20 +0200 Subject: [PATCH 3/5] Ran flake8 and black --- members/models/activity.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/members/models/activity.py b/members/models/activity.py index 2d25e9e3..748644de 100644 --- a/members/models/activity.py +++ b/members/models/activity.py @@ -78,8 +78,11 @@ class Meta: "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'" + "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): From 0b9a5ad83b7fa2f1a8c969fdba361edfcf44976f Mon Sep 17 00:00:00 2001 From: mhewel <58829786+mhewel@users.noreply.github.com> Date: Mon, 17 Jun 2024 21:47:10 +0200 Subject: [PATCH 4/5] Merged migrations --- ...activity_visible_activity_visible_from.py} | 11 +++++++++- members/migrations/0054_activity_visible.py | 22 ------------------- 2 files changed, 10 insertions(+), 23 deletions(-) rename members/migrations/{0053_activity_visible_from.py => 0053_activity_visible_activity_visible_from.py} (55%) delete mode 100644 members/migrations/0054_activity_visible.py diff --git a/members/migrations/0053_activity_visible_from.py b/members/migrations/0053_activity_visible_activity_visible_from.py similarity index 55% rename from members/migrations/0053_activity_visible_from.py rename to members/migrations/0053_activity_visible_activity_visible_from.py index b2e9491c..5989d0f5 100644 --- a/members/migrations/0053_activity_visible_from.py +++ b/members/migrations/0053_activity_visible_activity_visible_from.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.11 on 2024-06-01 07:45 +# Generated by Django 4.2.11 on 2024-06-17 19:46 from django.db import migrations, models import django.utils.timezone @@ -11,6 +11,15 @@ class Migration(migrations.Migration): ] 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", diff --git a/members/migrations/0054_activity_visible.py b/members/migrations/0054_activity_visible.py deleted file mode 100644 index 5fb33005..00000000 --- a/members/migrations/0054_activity_visible.py +++ /dev/null @@ -1,22 +0,0 @@ -# Generated by Django 4.2.11 on 2024-06-17 19:24 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ("members", "0053_activity_visible_from"), - ] - - 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", - ), - ), - ] From b55bf1253a6389f4a588cace2a69be066389c59b Mon Sep 17 00:00:00 2001 From: mhewel <58829786+mhewel@users.noreply.github.com> Date: Mon, 17 Jun 2024 21:51:56 +0200 Subject: [PATCH 5/5] Merged migrations --- members/migrations/0054_merge_20240617_2150.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 members/migrations/0054_merge_20240617_2150.py 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 = []