From c2944a218c7df2bb6a336336fe13758f96ee3e6a Mon Sep 17 00:00:00 2001 From: drosetti Date: Thu, 31 Oct 2024 09:49:03 +0100 Subject: [PATCH] code quality --- api_app/models.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/api_app/models.py b/api_app/models.py index d637d7968..4158d87f2 100644 --- a/api_app/models.py +++ b/api_app/models.py @@ -1794,12 +1794,6 @@ class SingletonModel(models.Model): Singleton is a desing pattern that allow only one istance of a class. """ - def save(self, *args, **kwargs): - # check required to delete the singleton instance and create a new one - if type(self).objects.count() == 0: - self.pk = 1 - super().save(*args, **kwargs) - class Meta: abstract = True constraints = [ @@ -1810,6 +1804,12 @@ class Meta: ), ] + def save(self, *args, **kwargs): + # check required to delete the singleton instance and create a new one + if type(self).objects.count() == 0: + self.pk = 1 + super().save(*args, **kwargs) + class LastElasticReportUpdate(SingletonModel): last_update_datetime = models.DateTimeField()