fix(translations): Disable updates to an existing translation

This commit is contained in:
Tom Hubrecht 2024-09-26 12:12:58 +02:00
parent 3b3f2dd34d
commit 941f2b031e
Signed by: thubrecht
SSH key fingerprint: SHA256:r+nK/SIcWlJ0zFZJGHtlAoRwq1Rm+WcKAm5ADYMoQPc

View file

@ -69,6 +69,14 @@ class Bylaws(LegalDocument):
verbose_name_plural = _("Règlements Intérieurs")
# class TermsAndConditions(LegalDocument):
# """
# Terms and Conditions of use regarding a service offered by the association.
# """
#
# service = models.ForeignKey(Service, on_delete=models.CASCADE)
class Translation(models.Model):
cas_login = models.CharField(max_length=255, unique=True)
username = models.CharField(max_length=255, unique=True)
@ -76,6 +84,12 @@ class Translation(models.Model):
def __str__(self) -> str:
return f"{self.cas_login}{self.username}"
def save(self, **kwargs) -> None: # pyright: ignore
# INFO: Only update the model if it does not already exist
# This will prevent a lot of pain
if self.pk is None:
return super().save(**kwargs)
class Meta: # pyright: ignore
verbose_name = _("Correspondance de login")
verbose_name_plural = _("Correspondances de login")