From 37e3a49ace784066d17387398cd68368c7f0e934 Mon Sep 17 00:00:00 2001 From: Jonas de Luna Skulberg Date: Tue, 12 Mar 2024 18:43:46 +0100 Subject: [PATCH] Add notification on update of lending instance --- lego/apps/lending/managers.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lego/apps/lending/managers.py b/lego/apps/lending/managers.py index 375865db2a..213de36d5f 100644 --- a/lego/apps/lending/managers.py +++ b/lego/apps/lending/managers.py @@ -26,6 +26,19 @@ def create(self, *args, **kwargs): notification.notify() return lending_instance + + def update(self, *args, **kwargs): + from lego.apps.lending.notifications import LendingInstanceNotification + + lending_instance = super().update(*args, **kwargs) + notification = LendingInstanceNotification( + lending_instance=lending_instance, + user=lending_instance.created_by, + ) + notification.notify() + + return lending_instance + def get_queryset(self): return super().get_queryset().select_related("created_by")