Skip to content

Commit

Permalink
Merge pull request #1270 from Amsterdam/feature/126604-skip-zienswijz…
Browse files Browse the repository at this point in the history
…e-after-intrekking-bb

126604 Skip zienswijze na intrekking BB-vergunning
  • Loading branch information
NvdLaan authored Oct 9, 2024
2 parents a58d348 + 2133c0c commit bf4989d
Show file tree
Hide file tree
Showing 6 changed files with 1,176 additions and 20 deletions.
9 changes: 9 additions & 0 deletions app/apps/summons/fixtures/fixture.json
Original file line number Diff line number Diff line change
Expand Up @@ -484,5 +484,14 @@
"workflow_option": "informatiebrief",
"name": "Informatiebrief"
}
},
{
"model": "summons.summontype",
"pk": 68,
"fields": {
"theme": 2,
"workflow_option": "geen_zienswijze",
"name": "Voornemen intrekking BB-vergunning (geen zienswijze)"
}
}
]
1,121 changes: 1,121 additions & 0 deletions app/apps/workflow/bpmn_files/default/summon/7.3.0/summon.bpmn

Large diffs are not rendered by default.

31 changes: 23 additions & 8 deletions app/apps/workflow/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,33 @@ class CaseWorkflow(models.Model):
serializer = BpmnSerializer

def get_workflow_exclude_options(self):
if self.workflow_type != CaseWorkflow.WORKFLOW_TYPE_SUMMON:
return []

summon_version = version.parse(self.workflow_version)

exclude_options = []

# Version is lower than 6.3, remove these options because they are not present in that BPMN version
if summon_version < version.parse("6.3.0"):
exclude_options = ["besluit", "informatiebrief", "geen_zienswijze"]
elif summon_version < version.parse("7.2.0"): # covers versions 6.3.0 to 7.1.0
exclude_options = ["informatiebrief", "geen_zienswijze"]
elif summon_version < version.parse("7.3.0"): # covers version 7.2.0
exclude_options = ["geen_zienswijze"]

return exclude_options

def get_workflow_exclude_names(self):
if self.workflow_type == CaseWorkflow.WORKFLOW_TYPE_SUMMON:
summon_version = version.parse(self.workflow_version)
# Version is lower than 6.3, remove these options because they are not present in that BPMN version
if summon_version < version.parse("6.3.0"):
exclude_options = ["besluit", "informatiebrief"]
# Version is 6.3.0 or 7.1.0
elif version.parse("6.3.0") <= summon_version < version.parse("7.2.0"):
exclude_options = ["informatiebrief"]
# Version is equal or higher than 7.3.0, remove this option because it's replaced by another route in the BPMN-model.
if summon_version >= version.parse("7.3.0"):
exclude_names = ["Voornemen intrekking BB-vergunning"]
else:
exclude_options = []
exclude_names = []

return exclude_options
return exclude_names

def get_lock_id(self):
return f"caseworkflow-lock-{self.id}"
Expand Down
25 changes: 17 additions & 8 deletions app/apps/workflow/tests/tests_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,33 +61,42 @@ def test_get_workflow_exclude_options(self):
exclude_options = workflow.get_workflow_exclude_options()
self.assertEqual(
exclude_options,
["informatiebrief"],
"Should exclude 'informatiebrief' for version 7.1.0",
["informatiebrief", "geen_zienswijze"],
"Should exclude 'informatiebrief' and 'geen_zienswijze' for version 7.1.0",
)

# Test case for version 6.0.0
workflow.workflow_version = "6.0.0"
exclude_options = workflow.get_workflow_exclude_options()
self.assertEqual(
exclude_options,
["besluit", "informatiebrief"],
"Should exclude 'besluit' and 'informatiebrief' for version below 6.3.0",
["besluit", "informatiebrief", "geen_zienswijze"],
"Should exclude 'besluit', 'informatiebrief' and 'geen_zienswijze' for version below 6.3.0",
)

# Test case for version 6.3.0
workflow.workflow_version = "6.3.0"
exclude_options = workflow.get_workflow_exclude_options()
self.assertEqual(
exclude_options,
["informatiebrief"],
"Should exclude 'informatiebrief' for version 6.3.0",
["informatiebrief", "geen_zienswijze"],
"Should exclude 'informatiebrief' and 'geen_zienswijze' for version 6.3.0",
)

# Test case for version 7.2.0 and above (e.g., 7.2.0)
# Test case for version 7.2.0
workflow.workflow_version = "7.2.0"
exclude_options = workflow.get_workflow_exclude_options()
self.assertEqual(
exclude_options,
["geen_zienswijze"],
"Should exclude 'geen_zienswijze' for version 7.2.0",
)

# Test case for version 7.3.0 and above (e.g., 7.3.0)
workflow.workflow_version = "7.3.0"
exclude_options = workflow.get_workflow_exclude_options()
self.assertEqual(
exclude_options,
[],
"Should not exclude any options for version 7.2.0 and above",
"Should not exclude any options for version 7.3.0 and above",
)
9 changes: 5 additions & 4 deletions app/apps/workflow/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,11 @@ def summon_types(self, request, pk):
caseUserTask = self.get_object()
theme = caseUserTask.case.theme
exclude_options = caseUserTask.workflow.get_workflow_exclude_options()
if exclude_options:
query_set = theme.summon_types.exclude(workflow_option__in=exclude_options)
else:
query_set = theme.summon_types.all()
exclude_names = caseUserTask.workflow.get_workflow_exclude_names()
# Theres's always an exclude_options or a exclude_names. Version is always above/equal or below "7.3.0".
query_set = theme.summon_types.exclude(
workflow_option__in=exclude_options
).exclude(name__in=exclude_names)

context = paginator.paginate_queryset(query_set, request)
serializer = SummonTypeSerializer(context, many=True)
Expand Down
1 change: 1 addition & 0 deletions app/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,7 @@ def get_redis_url():
"6.3.0": {},
"7.1.0": {},
"7.2.0": {},
"7.3.0": {},
},
},
"unoccupied": {
Expand Down

0 comments on commit bf4989d

Please sign in to comment.