Skip to content

Commit

Permalink
Merge pull request #1056 from CodingPirates/1055-feature-mulighed-for…
Browse files Browse the repository at this point in the history
…-at-skjule-aktiviteter-fra-forældrene

Nye felt for Aktiviteter : Fra hvilket tidspunkt kan aktiviteten være synlig ?
  • Loading branch information
lakridserne authored Jun 17, 2024
2 parents f617595 + b55bf12 commit d1ae6b6
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
2 changes: 2 additions & 0 deletions members/admin/activity_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ def formfield_for_foreignkey(self, db_field, request, **kwargs):
"end_date",
),
"member_justified",
"visible",
"visible_from",
),
},
),
Expand Down
31 changes: 31 additions & 0 deletions members/migrations/0053_activity_visible_activity_visible_from.py
Original file line number Diff line number Diff line change
@@ -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",
),
),
]
13 changes: 13 additions & 0 deletions members/migrations/0054_merge_20240617_2150.py
Original file line number Diff line number Diff line change
@@ -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 = []
10 changes: 10 additions & 0 deletions members/models/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions members/views/Activities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d1ae6b6

Please sign in to comment.