From 4574dfb0f9492ed1771829614064f61f23451258 Mon Sep 17 00:00:00 2001 From: Horilla Date: Tue, 2 Apr 2024 10:02:33 +0530 Subject: [PATCH] [UPDT] HORILLA: Updated HorillaModel by adding class methods to fetch object based on id and archive and unarchive object --- horilla/models.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/horilla/models.py b/horilla/models.py index 9adfc8ec1..ac48972f8 100644 --- a/horilla/models.py +++ b/horilla/models.py @@ -36,3 +36,15 @@ class HorillaModel(models.Model): if user.is_authenticated: self.created_by = user super(HorillaModel, self).save(*args, **kwargs) + + @classmethod + def find(cls, object_id): + # object_id = 1020 + return cls.objects.filter(id=object_id).first() + + @classmethod + def activate_deactivate(cls, object_id): + object = cls.find(object_id) + if object: + object.is_active = not object.is_active + object.save()