From 53ca39317ec08cfeeed7265a29c7e9adaf7a220f 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 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lego/apps/lending/managers.py b/lego/apps/lending/managers.py index 375865db2a..6b37615842 100644 --- a/lego/apps/lending/managers.py +++ b/lego/apps/lending/managers.py @@ -26,6 +26,20 @@ def create(self, *args, **kwargs): notification.notify() return lending_instance + + #TODO: We probably need another template for accepting instances + 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")