From 189ff32026310885902af78967eaadb36efdf39d Mon Sep 17 00:00:00 2001 From: Murhu Markus Date: Thu, 29 Jan 2026 10:05:59 +0200 Subject: [PATCH] Change how service requests A+ to show notifications Changed the behavior of sending notifications to students when editing feedback messages. --- feedback/forms.py | 7 ++++++- feedback/models.py | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/feedback/forms.py b/feedback/forms.py index 68f6d28..c8785a6 100644 --- a/feedback/forms.py +++ b/feedback/forms.py @@ -135,7 +135,12 @@ def get_notify(self): old_msg = "".join(old_msg.split()) new_msg = self.cleaned_data['response_msg'] or '' new_msg = "".join(new_msg.split()) - return Feedback.NOTIFY.NORMAL if old_msg != new_msg else Feedback.NOTIFY.NO + if new_msg == '': # empty message always removes notification + return Feedback.NOTIFY.REMOVE + elif old_msg == '' and new_msg != '': # empty to non-empty sends notification + return Feedback.NOTIFY.NORMAL + else: + return Feedback.NOTIFY.NO # editing non-empty message does not change notification status # FIXME: add support for instance.NOTIFY.IMPORTANT def save(self): # pylint: disable=arguments-differ diff --git a/feedback/models.py b/feedback/models.py index 70ff0e1..d45704a 100644 --- a/feedback/models.py +++ b/feedback/models.py @@ -407,8 +407,10 @@ class Meta: ('NO', 0, _('No notification')), ('NORMAL', 1, _('Normal notification')), ('IMPORTANT', 2, _('Important notification')), + ('REMOVE', 10, _('Remove notification')), ) NOTIFY_APLUS = { + NOTIFY.REMOVE: 'remove', NOTIFY.NORMAL: 'normal', NOTIFY.IMPORTANT: 'important', }