@@ -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" , "" )
0 commit comments