♻️(models) allow null titles on documents

We want to make it as fast as possible to create a new document.
We should not have any modal asking the title before creating the
document but rather show an "untitle document" title and let the
owner set it on the already created document.
This commit is contained in:
Samuel Paccoud - DINUM
2024-09-09 20:01:27 +02:00
committed by Samuel Paccoud
parent 2c3eef4dd9
commit 9b44e021fd
5 changed files with 43 additions and 9 deletions

View File

@@ -320,7 +320,7 @@ class BaseAccess(BaseModel):
class Document(BaseModel):
"""Pad document carrying the content."""
title = models.CharField(_("title"), max_length=255)
title = models.CharField(_("title"), max_length=255, null=True, blank=True)
link_reach = models.CharField(
max_length=20,
choices=LinkReachChoices.choices,
@@ -339,7 +339,7 @@ class Document(BaseModel):
verbose_name_plural = _("Documents")
def __str__(self):
return self.title
return str(self.title) if self.title else str(_("Untitled Document"))
def save(self, *args, **kwargs):
"""Write content to object storage only if _content has changed."""