[UPDT] HORILLA: Updated HorillaModel by adding class methods to fetch object based on id and archive and unarchive object

This commit is contained in:
Horilla
2024-04-02 10:02:33 +05:30
parent fc8d8a095e
commit 4574dfb0f9

View File

@@ -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()