add etherpad-check to clean method

This commit is contained in:
2022-03-17 12:25:25 +00:00
parent ae71180e65
commit f789fc17cb

View File

@@ -123,7 +123,6 @@ class Document(models.Model):
self.slug = slugify(self.title) self.slug = slugify(self.title)
pad_name = slugify(str(self.date) + "-" + self.task.slug + "-" + self.slug) pad_name = slugify(str(self.date) + "-" + self.task.slug + "-" + self.slug)
if len(pad_name) > 50: if len(pad_name) > 50:
raise ValidationError( raise ValidationError(
_( _(
@@ -132,12 +131,11 @@ class Document(models.Model):
params={"length": len(pad_name), "pad_name": pad_name}, params={"length": len(pad_name), "pad_name": pad_name},
) )
def save(self, *args, **kwargs): self.etherpad_key = create_pad(pad_name)
self.etherpad_key = create_pad( if not self.etherpad_key:
slugify(str(self.date) + "-" + self.task.slug + "-" + self.slug) raise ValidationError(
_(f"Etherpad '{pad_name}' konnte nicht erstellt werden."),
) )
super().save(*args, **kwargs)
def __str__(self): def __str__(self):
return self.title return self.title