[CHANGE] Better regex for exclusion in pre-commit

This commit is contained in:
Peter Pfeufer
2022-09-18 08:26:22 +00:00
committed by Ariel Rin
parent a9a7e03b80
commit b34661b35d
4 changed files with 31 additions and 10 deletions

View File

@@ -8,13 +8,13 @@ from uuid import uuid4
class AnalyticsIdentifier(models.Model):
identifier = models.UUIDField(default=uuid4,
editable=False)
editable=False)
def save(self, *args, **kwargs):
if not self.pk and AnalyticsIdentifier.objects.exists():
# Force a single object
raise ValidationError('There is can be only one \
AnalyticsIdentifier instance')
AnalyticsIdentifier instance')
self.pk = self.id = 1 # If this happens to be deleted and recreated, force it to be 1
return super().save(*args, **kwargs)