Skip to content

Commit

Permalink
code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
drosetti committed Oct 31, 2024
1 parent cc785f8 commit c2944a2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions api_app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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()

0 comments on commit c2944a2

Please sign in to comment.