Skip to content

Commit

Permalink
implement new informatiebrief route
Browse files Browse the repository at this point in the history
  • Loading branch information
NvdLaan committed Aug 15, 2024
1 parent 9ea2282 commit db3a705
Show file tree
Hide file tree
Showing 7 changed files with 1,215 additions and 15 deletions.
27 changes: 27 additions & 0 deletions app/apps/summons/fixtures/fixture.json
Original file line number Diff line number Diff line change
Expand Up @@ -439,5 +439,32 @@
"workflow_option": "besluit",
"name": "Besluit (geen boete / LOD)"
}
},
{
"model": "summons.summontype",
"pk": 63,
"fields": {
"theme": 3,
"workflow_option": "informatiebrief",
"name": "Informatiebrief"
}
},
{
"model": "summons.summontype",
"pk": 64,
"fields": {
"theme": 4,
"workflow_option": "informatiebrief",
"name": "Informatiebrief"
}
},
{
"model": "summons.summontype",
"pk": 65,
"fields": {
"theme": 7,
"workflow_option": "informatiebrief",
"name": "Informatiebrief"
}
}
]
1,111 changes: 1,111 additions & 0 deletions app/apps/workflow/bpmn_files/default/summon/7.2.0/summon.bpmn

Large diffs are not rendered by default.

20 changes: 12 additions & 8 deletions app/apps/workflow/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@

logger = logging.getLogger(__name__)

# Summon types with workflow option "besluit" are only available from version "6.3.0"
LTS_WORKFLOW_VERSION_SUMMON = "6.3.0"


class CaseWorkflow(models.Model):
WORKFLOW_TYPE_MAIN = "main_workflow"
Expand Down Expand Up @@ -153,12 +150,19 @@ class CaseWorkflow(models.Model):

serializer = BpmnSerializer

def is_workflow_version_supported(self):
def get_workflow_exclude_options(self):
if self.workflow_type == CaseWorkflow.WORKFLOW_TYPE_SUMMON:
return version.parse(self.workflow_version) >= version.parse(
LTS_WORKFLOW_VERSION_SUMMON
)
return True
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"]
else:
exclude_options = []

return exclude_options

def get_lock_id(self):
return f"caseworkflow-lock-{self.id}"
Expand Down
48 changes: 48 additions & 0 deletions app/apps/workflow/tests/tests_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,51 @@ def test_can_get_workflow_spec(self):
)

self.assertEquals(workflow.get_workflow_spec().__class__, BpmnProcessSpec)

def test_get_workflow_exclude_options(self):
"""Tests can get workflow spec"""

theme = baker.make(CaseTheme, name=settings.DEFAULT_THEME)
case = baker.make(Case, theme=theme)
workflow = baker.make(
CaseWorkflow,
case=case,
workflow_type=CaseWorkflow.WORKFLOW_TYPE_SUMMON,
id=8,
workflow_version="7.1.0",
workflow_theme_name="default",
data={},
)
exclude_options = workflow.get_workflow_exclude_options()
self.assertEqual(
exclude_options,
["informatiebrief"],
"Should exclude 'informatiebrief' 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",
)

# 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",
)

# Test case for version 7.2.0 and above (e.g., 7.2.0)
workflow.workflow_version = "7.2.0"
exclude_options = workflow.get_workflow_exclude_options()
self.assertEqual(
exclude_options,
[],
"Should not exclude any options for version 7.2.0 and above",
)
12 changes: 12 additions & 0 deletions app/apps/workflow/user_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1016,3 +1016,15 @@ class task_doorzon_pv(user_task):

class task_sub_workflow_terug_melding_bag(user_task):
"""Terug melding BAG"""


class task_nakijken_informatiebrief(user_task):
"""task_nakijken_informatiebrief"""

_task_name = "task_nakijken_informatiebrief"


class task_verwerken_informatiebrief(user_task):
"""task_nakijken_informatiebrief"""

_task_name = "task_verwerken_informatiebrief"
11 changes: 4 additions & 7 deletions app/apps/workflow/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,11 @@ def summon_types(self, request, pk):
paginator = LimitOffsetPagination()
caseUserTask = self.get_object()
theme = caseUserTask.case.theme

# Summon types with workflow option "besluit" are only available from version "6.3.0"
if caseUserTask.workflow.is_workflow_version_supported():
# The version is equal to or higher than 6.3.0" so return all types for theme.
query_set = theme.summon_types.all()
exclude_options = caseUserTask.workflow.get_workflow_exclude_options()
if exclude_options:
query_set = theme.summon_types.exclude(workflow_option__in=exclude_options)
else:
# The version is lower than 6.3.0" so exclude "besluit".
query_set = theme.summon_types.exclude(workflow_option="besluit")
query_set = theme.summon_types.all()

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 @@ -1297,6 +1297,7 @@ def get_redis_url():
"4.1.0": {},
"6.3.0": {},
"7.1.0": {},
"7.2.0": {},
},
},
"unoccupied": {
Expand Down

0 comments on commit db3a705

Please sign in to comment.