1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-06-20 17:41:55 +02:00

When data is imported from the NK15, prevent users whenever some aliases are deleted

This commit is contained in:
Yohann D'ANELLO
2020-08-24 12:41:51 +02:00
parent 550242226e
commit b25935e579
6 changed files with 444 additions and 425 deletions

View File

@ -222,7 +222,7 @@ class Alias(models.Model):
normalized_name = models.CharField(
max_length=255,
unique=True,
default='',
blank=False,
editable=False,
)
note = models.ForeignKey(
@ -257,6 +257,8 @@ class Alias(models.Model):
if len(normalized_name) >= 255:
raise ValidationError(_('Alias is too long.'),
code='alias_too_long')
if not normalized_name:
raise ValidationError(_('This alias contains only complex character. Please use a more simple alias.'))
try:
sim_alias = Alias.objects.get(normalized_name=normalized_name)
if self != sim_alias: