Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement new informatiebrief route #1259

Merged
merged 5 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions app/apps/summons/fixtures/fixture.json
Original file line number Diff line number Diff line change
Expand Up @@ -439,5 +439,50 @@
"workflow_option": "besluit",
"name": "Besluit (geen boete / LOD)"
}
},
{
"model": "summons.summontype",
"pk": 63,
"fields": {
"theme": 8,
"workflow_option": "aanschrijvingen",
"name": "Voornemen besluit"
}
},
{
"model": "summons.summontype",
"pk": 64,
"fields": {
"theme": 3,
"workflow_option": "informatiebrief",
"name": "Informatiebrief"
}
},
{
"model": "summons.summontype",
"pk": 65,
"fields": {
"theme": 4,
"workflow_option": "informatiebrief",
"name": "Informatiebrief"
}
},
{
"model": "summons.summontype",
"pk": 66,
"fields": {
"theme": 7,
"workflow_option": "informatiebrief",
"name": "Informatiebrief"
}
},
{
"model": "summons.summontype",
"pk": 67,
"fields": {
"theme": 2,
"workflow_option": "informatiebrief",
"name": "Informatiebrief"
}
}
]
1,107 changes: 1,107 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
Loading