Skip to content

Commit 17eab47

Browse files
authored
Fix the email sending and status change processes in the Suricate workflow (#5092)
* Send emails to Suricate when changing report status * Format if conditions in report form * Add an entry in the changelog
1 parent 67bdb2b commit 17eab47

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CHANGELOG
88
**Bug fixes**
99

1010
* Draft path can be add by user without permission to add regular path
11+
* Fix the email sending and status change processes in the Suricate workflow.
1112

1213

1314
2.121.0 (2025-11-14)

geotrek/feedback/forms.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,9 @@ def __init__(self, *args, **kwargs):
9696
identifier__in=next_statuses
9797
)
9898
# current_user
99-
if (
99+
if self.old_status.identifier not in ["filed", "waiting"] or (
100100
WorkflowManager.objects.first()
101-
and self.old_status.identifier not in ["filed", "waiting"]
102-
or kwargs["user"] != WorkflowManager.objects.first().user
101+
and kwargs["user"] != WorkflowManager.objects.first().user
103102
):
104103
# only manager can reassign a report
105104
self.fields["current_user"].widget = HiddenInput()
@@ -192,7 +191,11 @@ def save(self, *args, **kwargs):
192191
if (not creation) and settings.SURICATE_WORKFLOW_ENABLED:
193192
waiting_status = ReportStatus.objects.get(identifier="waiting")
194193
# Assign report through moderation step
195-
if self.old_status.identifier in ["filed"] and report.current_user:
194+
if (
195+
self.old_status.identifier in ["filed"]
196+
and report.status.identifier in ["waiting"]
197+
and report.current_user
198+
):
196199
msg = self.cleaned_data.get("message_supervisor", "")
197200
report.notify_current_user(msg)
198201
report.assigned_handler = report.current_user
@@ -229,8 +232,10 @@ def save(self, *args, **kwargs):
229232
self.old_status.identifier != report.status.identifier
230233
or self.old_user != report.current_user
231234
# do not notify suricate when the supervisor is reassigned
232-
and self.old_status.identifier in ["waiting"]
233-
and report.status.identifier in ["waiting"]
235+
and not (
236+
self.old_status.identifier in ["waiting"]
237+
and report.status.identifier in ["waiting"]
238+
)
234239
):
235240
msg_sentinel = self.cleaned_data.get("message_sentinel", "")
236241
msg_admins = self.cleaned_data.get("message_administrators", "")

geotrek/feedback/tests/test_forms.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ def test_workflow_assign_supervisor_step(self, mocked_post, mocked_get):
197197
# When assigning a user to a report
198198
data = {
199199
"current_user": str(self.other_user.pk),
200+
"status": self.waiting_status,
200201
"email": "[email protected]",
201202
"geom": self.filed_report.geom,
202203
"message_sentinel": "Your message",
@@ -269,6 +270,7 @@ def test_workflow_assign_manager_step(self, mocked_post, mocked_get):
269270
# When assigning a user to a report
270271
data = {
271272
"current_user": str(self.workflow_manager.user.pk),
273+
"status": self.waiting_status,
272274
"email": "[email protected]",
273275
"geom": self.filed_report.geom,
274276
"message_sentinel": "Your message",

0 commit comments

Comments
 (0)