Skip to content

Commit e1a3e62

Browse files
feat(enrolment): add is_part_of_cultural_route boolean field support
Add a required `is_part_of_cultural_route` field to enrolments and queue enrolments and their related reports. Updating enrolments through admin view intentionally does not require `is_part_of_cultural_route` to be always updated. Add `is_part_of_cultural_route` to Django admin's EnrolmentReportAdmin, to its list display and add a boolean filter for the value. Also update snapshots as they changed to some other set of random values, probably because of model change. Refs: PT-453
1 parent a07b4b8 commit e1a3e62

16 files changed

Lines changed: 505 additions & 38 deletions

File tree

gdpr/tests/__snapshots__/test_gdpr_api.ambr

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
'children': list([
1919
dict({
2020
'key': 'START_TIME',
21-
'value': '2010-07-23T14:55:55.542261+00:00',
21+
'value': '2000-01-15T19:13:18.149871+00:00',
2222
}),
2323
dict({
2424
'key': 'END_TIME',
25-
'value': '2008-11-04T18:51:30.730104+00:00',
25+
'value': '1987-01-24T05:08:40.298940+00:00',
2626
}),
2727
dict({
2828
'key': 'CREATED_AT',
@@ -36,7 +36,7 @@
3636
'children': list([
3737
dict({
3838
'key': 'LINKED_EVENT_ID',
39-
'value': 'FrTcm',
39+
'value': 'Tcmct',
4040
}),
4141
dict({
4242
'key': 'ORGANISATION',
@@ -65,11 +65,11 @@
6565
}),
6666
dict({
6767
'key': 'UNIT_NAME',
68-
'value': 'National since collection goal natural. Subject take stop debate.',
68+
'value': 'Adult economy a to analysis senior officer. What method admit fact force.',
6969
}),
7070
dict({
7171
'key': 'GROUP_SIZE',
72-
'value': 857,
72+
'value': 186,
7373
}),
7474
dict({
7575
'key': 'AMOUNT_OF_ADULT',
@@ -81,7 +81,7 @@
8181
}),
8282
dict({
8383
'key': 'EXTRA_NEEDS',
84-
'value': 'Whose our politics contain blood interview. Cup must tough edge part. Respond pressure people.',
84+
'value': 'So two avoid use actually difficult. House society blood trial. Top really study young whose our.',
8585
}),
8686
dict({
8787
'key': 'PREFERRED_TIMES',
@@ -178,11 +178,11 @@
178178
'children': list([
179179
dict({
180180
'key': 'LINKED_EVENT_ID',
181-
'value': 'NoYfT',
181+
'value': 'EguWh',
182182
}),
183183
dict({
184184
'key': 'ORGANISATION',
185-
'value': 'Rosario and Sons',
185+
'value': 'Allen and Sons',
186186
}),
187187
dict({
188188
'key': 'CONTACT_PERSON',
@@ -483,11 +483,11 @@
483483
'children': list([
484484
dict({
485485
'key': 'START_TIME',
486-
'value': '2010-07-23T14:55:55.542261+00:00',
486+
'value': '2000-01-15T19:13:18.149871+00:00',
487487
}),
488488
dict({
489489
'key': 'END_TIME',
490-
'value': '2008-11-04T18:51:30.730104+00:00',
490+
'value': '1987-01-24T05:08:40.298940+00:00',
491491
}),
492492
dict({
493493
'key': 'CREATED_AT',
@@ -501,7 +501,7 @@
501501
'children': list([
502502
dict({
503503
'key': 'LINKED_EVENT_ID',
504-
'value': 'FrTcm',
504+
'value': 'Tcmct',
505505
}),
506506
dict({
507507
'key': 'ORGANISATION',
@@ -605,11 +605,11 @@
605605
'children': list([
606606
dict({
607607
'key': 'LINKED_EVENT_ID',
608-
'value': 'NoYfT',
608+
'value': 'EguWh',
609609
}),
610610
dict({
611611
'key': 'ORGANISATION',
612-
'value': 'Rosario and Sons',
612+
'value': 'Allen and Sons',
613613
}),
614614
dict({
615615
'key': 'CONTACT_PERSON',
@@ -641,11 +641,11 @@
641641
'children': list([
642642
dict({
643643
'key': 'START_TIME',
644-
'value': '2010-07-23T14:55:55.542261+00:00',
644+
'value': '2000-01-15T19:13:18.149871+00:00',
645645
}),
646646
dict({
647647
'key': 'END_TIME',
648-
'value': '2008-11-04T18:51:30.730104+00:00',
648+
'value': '1987-01-24T05:08:40.298940+00:00',
649649
}),
650650
dict({
651651
'key': 'CREATED_AT',
@@ -659,7 +659,7 @@
659659
'children': list([
660660
dict({
661661
'key': 'LINKED_EVENT_ID',
662-
'value': 'FrTcm',
662+
'value': 'Tcmct',
663663
}),
664664
dict({
665665
'key': 'ORGANISATION',

occurrences/factories.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ class Meta:
119119

120120

121121
class EventQueueEnrolmentFactory(factory.django.DjangoModelFactory):
122+
is_part_of_cultural_route = factory.Faker("boolean")
122123
study_group = factory.SubFactory(StudyGroupFactory)
123124
p_event = factory.SubFactory(PalvelutarjotinEventFactory)
124125
person = factory.SubFactory(PersonFactory)
@@ -129,6 +130,7 @@ class Meta:
129130

130131

131132
class EnrolmentFactory(factory.django.DjangoModelFactory):
133+
is_part_of_cultural_route = factory.Faker("boolean")
132134
study_group = factory.SubFactory(StudyGroupFactory)
133135
occurrence = factory.SubFactory(OccurrenceFactory)
134136
person = factory.SubFactory(PersonFactory)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Generated by Django 5.2.14 on 2026-05-28 12:43
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
dependencies = [
8+
("occurrences", "0044_add_group_name_to_studygroup_order_by"),
9+
]
10+
11+
operations = [
12+
migrations.AddField(
13+
model_name="enrolment",
14+
name="is_part_of_cultural_route",
15+
field=models.BooleanField(
16+
default=False,
17+
help_text="Is enrolment part of a cultural route? True means yes, False means no, I don't know or unanswered.",
18+
verbose_name="is part of cultural route",
19+
),
20+
),
21+
migrations.AddField(
22+
model_name="eventqueueenrolment",
23+
name="is_part_of_cultural_route",
24+
field=models.BooleanField(
25+
default=False,
26+
help_text="Is enrolment part of a cultural route? True means yes, False means no, I don't know or unanswered.",
27+
verbose_name="is part of cultural route",
28+
),
29+
),
30+
]

occurrences/models.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,14 @@ def user_can_view(self, user: User):
843843

844844

845845
class EnrolmentBase(WithDeletablePersonModel):
846+
is_part_of_cultural_route = models.BooleanField(
847+
default=False,
848+
verbose_name=_("is part of cultural route"),
849+
help_text=_(
850+
"Is enrolment part of a cultural route? "
851+
"True means yes, False means no, I don't know or unanswered."
852+
),
853+
)
846854
notification_type = models.CharField(
847855
max_length=250,
848856
choices=NOTIFICATION_TYPES,
@@ -976,6 +984,7 @@ def create_enrolment(self, occurrence: Occurrence):
976984
enrolment = Enrolment(
977985
occurrence=occurrence,
978986
study_group=self.study_group,
987+
is_part_of_cultural_route=self.is_part_of_cultural_route,
979988
notification_type=self.notification_type,
980989
person=self.person,
981990
)

occurrences/schema.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,13 @@ class StudyGroupInput(graphene.InputObjectType):
710710

711711
class EnrolInputBase:
712712
study_group = StudyGroupInput(description="Study group data", required=True)
713+
is_part_of_cultural_route = graphene.Boolean(
714+
description=(
715+
"Is the enrolment part of a cultural route? "
716+
"False = No / I don't know, True = Yes."
717+
),
718+
required=True,
719+
)
713720
notification_type = NotificationTypeEnum()
714721
person = PersonNodeInput(
715722
description="Leave blank if the contact person is "
@@ -747,6 +754,7 @@ def mutate_and_get_payload(cls, root, info, **kwargs):
747754
p_event = PalvelutarjotinEvent.objects.get(id=p_event_id)
748755
study_group = create_study_group(kwargs.pop("study_group"))
749756
contact_person_data = kwargs.pop("person", None)
757+
is_part_of_cultural_route = kwargs.pop("is_part_of_cultural_route")
750758
notification_type = kwargs.pop(
751759
"notification_type",
752760
EventQueueEnrolment._meta.get_field("notification_type").get_default(),
@@ -760,6 +768,7 @@ def mutate_and_get_payload(cls, root, info, **kwargs):
760768
study_group=study_group,
761769
p_event=p_event,
762770
person=person,
771+
is_part_of_cultural_route=is_part_of_cultural_route,
763772
notification_type=notification_type,
764773
)
765774
return EnrolEventQueueMutation(event_queue_enrolment=event_queue_enrolment)
@@ -860,6 +869,7 @@ def mutate_and_get_payload(cls, root, info, **kwargs):
860869
kwargs.pop("captcha_key", None)
861870
study_group = create_study_group(kwargs.pop("study_group"))
862871
contact_person_data = kwargs.pop("person", None)
872+
is_part_of_cultural_route = kwargs.pop("is_part_of_cultural_route")
863873
notification_type = kwargs.pop(
864874
"notification_type",
865875
Enrolment._meta.get_field("notification_type").get_default(),
@@ -880,6 +890,7 @@ def mutate_and_get_payload(cls, root, info, **kwargs):
880890
study_group=study_group,
881891
occurrences=occurrences,
882892
person=person,
893+
is_part_of_cultural_route=is_part_of_cultural_route,
883894
notification_type=notification_type,
884895
send_notifications_on_auto_acceptance=send_notifications,
885896
)
@@ -921,6 +932,7 @@ def mutate_and_get_payload(cls, root, info, **kwargs):
921932
class UpdateEnrolmentMutation(graphene.relay.ClientIDMutation):
922933
class Input:
923934
enrolment_id = graphene.GlobalID()
935+
is_part_of_cultural_route = graphene.Boolean(required=False)
924936
notification_type = NotificationTypeEnum()
925937
study_group = StudyGroupInput(description="Study group input")
926938
person = PersonNodeInput(
@@ -935,9 +947,12 @@ class Input:
935947
@transaction.atomic
936948
@map_enums_to_values_in_kwargs
937949
def mutate_and_get_payload(cls, root, info, **kwargs):
938-
enrolment = get_editable_obj_from_global_id(
950+
enrolment: Enrolment = get_editable_obj_from_global_id(
939951
info, kwargs.pop("enrolment_id"), Enrolment
940952
)
953+
# Use enrolment's existing value if not given or given None:
954+
if kwargs.get("is_part_of_cultural_route") is None:
955+
kwargs["is_part_of_cultural_route"] = enrolment.is_part_of_cultural_route
941956
study_group = enrolment.study_group
942957
study_group_data = kwargs.pop("study_group", None)
943958
if study_group_data:

occurrences/schema_services.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ def enrol_to_occurrence(
260260
study_group: StudyGroup,
261261
occurrences: List[Occurrence],
262262
person: Person,
263+
is_part_of_cultural_route: bool,
263264
notification_type,
264265
send_notifications_on_auto_acceptance=True,
265266
):
@@ -272,6 +273,7 @@ def enrol_to_occurrence(
272273
study_group=study_group,
273274
occurrence=occurrence,
274275
person=person,
276+
is_part_of_cultural_route=is_part_of_cultural_route,
275277
notification_type=notification_type,
276278
)
277279

@@ -300,6 +302,7 @@ def enrol_to_event_queue(
300302
study_group: StudyGroup,
301303
p_event: PalvelutarjotinEvent,
302304
person: Person,
305+
is_part_of_cultural_route: bool,
303306
notification_type: str,
304307
):
305308
if not p_event.is_queueing_allowed:
@@ -315,6 +318,7 @@ def enrol_to_event_queue(
315318
p_event=p_event,
316319
study_group=study_group,
317320
person=person,
321+
is_part_of_cultural_route=is_part_of_cultural_route,
318322
notification_type=notification_type,
319323
enrolment_time=timezone.now(),
320324
)

occurrences/tests/__snapshots__/test_api.ambr

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -988,8 +988,8 @@
988988
}),
989989
'status': 'HAS_NO_ENROLMENTS',
990990
'studyGroup': dict({
991-
'groupName': 'Away watch above bad car. List short color produce include threat.',
992-
'preferredTimes': 'Street sign education field.',
991+
'groupName': 'That story claim. Case skin machine. Congress night street good break likely skill.',
992+
'preferredTimes': 'Much theory pay color fight.',
993993
}),
994994
}),
995995
}),
@@ -1005,7 +1005,10 @@
10051005
}),
10061006
'status': 'HAS_NO_ENROLMENTS',
10071007
'studyGroup': dict({
1008-
'groupName': 'Before charge difficult number. Leave part and test benefit.',
1008+
'groupName': '''
1009+
These international majority stuff.
1010+
Poor crime chair eight. Leave part and test benefit.
1011+
''',
10091012
'preferredTimes': 'Hotel near deal.',
10101013
}),
10111014
}),
@@ -1056,8 +1059,8 @@
10561059
}),
10571060
'status': 'HAS_NO_ENROLMENTS',
10581061
'studyGroup': dict({
1059-
'groupName': 'Project hope eight week still. Mission program point piece simple too walk. Talk hand price author.',
1060-
'preferredTimes': 'On performance detail sure.',
1062+
'groupName': 'Focus author huge great. Institution more happen million hit listen.',
1063+
'preferredTimes': 'House hear culture.',
10611064
}),
10621065
}),
10631066
}),

occurrences/tests/__snapshots__/test_notifications.ambr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,17 +258,17 @@
258258
no-reply@hel.ninja|['brett47@example.com']|Occurrence enrolment EN|
259259
Event EN: Raija Malka & Kaija Saariaho: Blick
260260
Extra event info: ytHjL
261-
Study group: Close term where up notice environment father stay. Hold project month similar support line.
261+
Study group: Stop available listen specific.
262262
Occurrence: 18.04.2002 09.53
263-
Person: sandra56@example.net
263+
Person: srobinson@example.net
264264
''',
265265
'''
266266
no-reply@hel.ninja|['brett47@example.com']|Occurrence unenrolment EN|
267267
Event EN: Raija Malka & Kaija Saariaho: Blick
268268
Extra event info: ytHjL
269-
Study group: Close term where up notice environment father stay. Hold project month similar support line.
269+
Study group: Stop available listen specific.
270270
Occurrence: 18.04.2002 09.53
271-
Person: sandra56@example.net
271+
Person: srobinson@example.net
272272
''',
273273
])
274274
# ---

0 commit comments

Comments
 (0)