diff options
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/forms_common.py | 6 | ||||
-rw-r--r-- | ishtar_common/models.py | 28 | ||||
-rw-r--r-- | ishtar_common/models_imports.py | 14 | ||||
-rw-r--r-- | ishtar_common/utils.py | 9 |
4 files changed, 30 insertions, 27 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py index cccae23eb..0f458ec51 100644 --- a/ishtar_common/forms_common.py +++ b/ishtar_common/forms_common.py @@ -1936,7 +1936,9 @@ class MergeOrganizationForm(MergeForm): TO_KEY = "to_organization" -def get_image_help(): +def get_image_help(help_for_doc=False): + if help_for_doc: + return max_size_help if not settings.IMAGE_MAX_SIZE: return max_size_help() return ( @@ -2141,7 +2143,7 @@ class DocumentForm(forms.ModelForm, CustomForm, ManageOldType): label=pgettext("Not directory", "File"), max_length=255, required=False, - help_text=max_size_help(), + help_text=max_size_help, validators=[file_size_validator], ) reference = forms.CharField( diff --git a/ishtar_common/models.py b/ishtar_common/models.py index c7fe7be8a..688197c73 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -484,14 +484,14 @@ class ImageModel(models.Model, ImageContainerModel): blank=True, null=True, max_length=255, - help_text=max_size_help(), + help_text=max_size_help, ) thumbnail = models.ImageField( upload_to=get_image_path, blank=True, null=True, max_length=255, - help_text=max_size_help(), + help_text=max_size_help, ) DUPLICATE_EXCLUDE = ["image", "thumbnail"] IMAGE_MAX_SIZE = settings.IMAGE_MAX_SIZE @@ -587,63 +587,63 @@ class RelationItem(models.Model): null=True, blank=True, upload_to=get_image_path, - help_text=max_size_help(), + help_text=max_size_help, ) relation_bitmap_image = models.FileField( _("Generated relation image (PNG)"), null=True, blank=True, upload_to=get_image_path, - help_text=max_size_help(), + help_text=max_size_help, ) relation_dot = models.FileField( _("Generated relation image (DOT)"), null=True, blank=True, upload_to=get_image_path, - help_text=max_size_help(), + help_text=max_size_help, ) relation_image_above = models.FileField( _("Generated above relation image (SVG)"), null=True, blank=True, upload_to=get_image_path, - help_text=max_size_help(), + help_text=max_size_help, ) relation_dot_above = models.FileField( _("Generated above relation image (DOT)"), null=True, blank=True, upload_to=get_image_path, - help_text=max_size_help(), + help_text=max_size_help, ) relation_bitmap_image_above = models.FileField( _("Generated above relation image (PNG)"), null=True, blank=True, upload_to=get_image_path, - help_text=max_size_help(), + help_text=max_size_help, ) relation_image_below = models.FileField( _("Generated below relation image (SVG)"), null=True, blank=True, upload_to=get_image_path, - help_text=max_size_help(), + help_text=max_size_help, ) relation_dot_below = models.FileField( _("Generated below relation image (DOT)"), null=True, blank=True, upload_to=get_image_path, - help_text=max_size_help(), + help_text=max_size_help, ) relation_bitmap_image_below = models.FileField( _("Generated below relation image (PNG)"), null=True, blank=True, upload_to=get_image_path, - help_text=max_size_help(), + help_text=max_size_help, ) class Meta: @@ -2087,7 +2087,7 @@ class DocumentTemplate(models.Model): upload_to="templates/%Y/", blank=True, null=True, - help_text=max_size_help(), + help_text=max_size_help, ) export_format = models.CharField(_("Export format"), max_length=4, choices=EXPORT_FORMATS, blank=True, default="") label_template = models.FileField( @@ -2095,7 +2095,7 @@ class DocumentTemplate(models.Model): upload_to="templates/%Y/", blank=True, null=True, - help_text=max_size_help(), + help_text=max_size_help, ) label_targets = models.TextField( _("Labels: targets for labels in the LibreOffice file"), @@ -4574,7 +4574,7 @@ class Document( blank=True, null=True, max_length=255, - help_text=max_size_help(), + help_text=max_size_help, ) index = models.IntegerField(verbose_name=_("Index"), blank=True, null=True) external_id = models.TextField(_("External ID"), blank=True, default="") diff --git a/ishtar_common/models_imports.py b/ishtar_common/models_imports.py index a499a9b12..9045de0c2 100644 --- a/ishtar_common/models_imports.py +++ b/ishtar_common/models_imports.py @@ -1390,7 +1390,7 @@ class BaseImport(models.Model, OwnPerms, SheetItem): _("Imported file"), upload_to="upload/imports/%Y/%m/", max_length=220, - help_text=max_size_help(), + help_text=max_size_help, blank=True, null=True, ) @@ -1400,7 +1400,7 @@ class BaseImport(models.Model, OwnPerms, SheetItem): blank=True, null=True, max_length=220, - help_text=max_size_help(), + help_text=max_size_help, ) archive_file = models.FileField( _("Archive file"), @@ -1408,7 +1408,7 @@ class BaseImport(models.Model, OwnPerms, SheetItem): blank=True, null=True, max_length=255, - help_text=max_size_help(), + help_text=max_size_help, ) encoding = models.CharField( _("Encoding"), choices=ENCODINGS, default="utf-8", max_length=15, @@ -1933,7 +1933,7 @@ class Import(BaseImport): _("Imported values"), upload_to="upload/imports/%Y/%m/", max_length=220, - help_text=max_size_help(), + help_text=max_size_help, blank=True, null=True, ) @@ -1943,7 +1943,7 @@ class Import(BaseImport): blank=True, null=True, max_length=255, - help_text=max_size_help(), + help_text=max_size_help, ) result_file = models.FileField( _("Result file"), @@ -1951,7 +1951,7 @@ class Import(BaseImport): blank=True, null=True, max_length=255, - help_text=max_size_help(), + help_text=max_size_help, ) match_file = models.FileField( _("Match file"), @@ -1959,7 +1959,7 @@ class Import(BaseImport): blank=True, null=True, max_length=255, - help_text=max_size_help(), + help_text=max_size_help, ) state = models.CharField( _("State"), max_length=2, choices=IMPORT_STATE, default="C" diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index d4453ff5a..95a7ebbaa 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -2005,10 +2005,11 @@ def m2m_historization_changed(sender, **kwargs): obj.save() -def max_size_help(): - msg = str(_("The maximum supported file size is {} Mo.")).format( - settings.MAX_UPLOAD_SIZE - ) +def max_size_help(help_for_doc=False): + max_size = settings.MAX_UPLOAD_SIZE + if help_for_doc: + max_size = '`MAX_UPLOAD_SIZE`' + msg = str(_("The maximum supported file size is {} Mo.")).format(max_size) return msg |