diff options
Diffstat (limited to 'ishtar_common')
| -rw-r--r-- | ishtar_common/forms_common.py | 15 | ||||
| -rw-r--r-- | ishtar_common/models.py | 18 | ||||
| -rw-r--r-- | ishtar_common/models_imports.py | 25 | ||||
| -rw-r--r-- | ishtar_common/utils.py | 7 | 
4 files changed, 38 insertions, 27 deletions
| diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py index b461d6266..47a282ab7 100644 --- a/ishtar_common/forms_common.py +++ b/ishtar_common/forms_common.py @@ -44,7 +44,8 @@ from ishtar_common.templatetags.link_to_window import simple_link_to_window  from forms import FinalForm, FormSet, reverse_lazy, name_validator, \      TableSelect, ManageOldType, CustomForm, FieldType, FormHeader, \      FormSetWithDeleteSwitches, IshtarForm, get_data_from_formset -from ishtar_common.utils import is_downloadable, clean_session_cache +from ishtar_common.utils import is_downloadable, clean_session_cache, \ +    max_size_help  from archaeological_operations.models import Operation  from archaeological_context_records.models import ContextRecord @@ -1072,11 +1073,13 @@ class MergeOrganizationForm(MergeForm):  def get_image_help():      if not settings.IMAGE_MAX_SIZE: -        return "" -    return _(u"<p>Heavy images are resized to: %(width)dx%(height)d " -             u"(ratio is preserved).</p>") \ +        return max_size_help() +    return unicode( +        _(u"Heavy images are resized to: %(width)dx%(height)d " +             u"(ratio is preserved).") \             % {'width': settings.IMAGE_MAX_SIZE[0], -              'height': settings.IMAGE_MAX_SIZE[1]} +              'height': settings.IMAGE_MAX_SIZE[1]}) + " " + unicode( +        max_size_help())  ####################### @@ -1108,7 +1111,7 @@ class DocumentForm(forms.ModelForm, CustomForm, ManageOldType):          max_length=255, required=False, widget=widgets.ImageFileInput())      associated_file = forms.FileField(          label=pgettext(u"Not directory", u"File"), max_length=255, -        required=False) +        required=False, help_text=max_size_help())      reference = forms.CharField(          label=_(u"Reference"),          validators=[validators.MaxLengthValidator(100)], required=False) diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 71868cb63..73366e35a 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -27,7 +27,6 @@ from importlib import import_module  from jinja2 import TemplateSyntaxError  import logging  import os -import pytz  import re  import shutil  import tempfile @@ -56,7 +55,6 @@ from django.db.utils import DatabaseError  from django.template.defaultfilters import slugify  from django.utils.functional import lazy  from django.utils.safestring import SafeUnicode, mark_safe -#from django.utils.timezone import now, timedelta  from django.utils.translation import ugettext_lazy as _, ugettext, \      pgettext_lazy, activate, deactivate  from secretary import Renderer as SecretaryRenderer @@ -73,7 +71,7 @@ from ishtar_common.models_imports import ImporterModel, ImporterType, \      Import, TargetKeyGroup  from ishtar_common.utils import get_cache, disable_for_loaddata, create_slug, \      get_all_field_names, merge_tsvectors, cached_label_changed, \ -    generate_relation_graph +    generate_relation_graph, max_size_help  __all__ = [      'ImporterModel', 'ImporterType', 'ImporterDefault', 'ImporterDefaultValues', @@ -992,9 +990,10 @@ def get_image_path(instance, filename):  class ImageModel(models.Model):      image = models.ImageField(upload_to=get_image_path, blank=True, null=True, -                              max_length=255) -    thumbnail = models.ImageField(upload_to=get_image_path, blank=True, -                                  null=True, max_length=255) +                              max_length=255, 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())      IMAGE_MAX_SIZE = settings.IMAGE_MAX_SIZE      THUMB_MAX_SIZE = settings.THUMB_MAX_SIZE      IMAGE_PREFIX = '' @@ -1115,7 +1114,7 @@ class RelationItem(models.Model):      """      relation_image = models.FileField(          _(u"Generated relation image (SVG)"), null=True, blank=True, -        upload_to=get_image_path +        upload_to=get_image_path, help_text=max_size_help()      )      class Meta: @@ -2538,7 +2537,7 @@ class DocumentTemplate(models.Model):      slug = models.SlugField(_(u"Slug"), blank=True, null=True, max_length=100,                              unique=True)      template = models.FileField( -        _(u"Template"), upload_to="templates/%Y/") +        _(u"Template"), upload_to="templates/%Y/", help_text=max_size_help())      associated_object_name = models.CharField(          _(u"Associated object"), max_length=100, choices=CLASSNAMES)      available = models.BooleanField(_(u"Available"), default=True) @@ -3896,7 +3895,8 @@ class Document(OwnPerms, ImageModel, FullSearch, Imported):      title = models.TextField(_(u"Title"), blank=True, default='')      associated_file = models.FileField( -        upload_to=get_image_path, blank=True, null=True, max_length=255) +        upload_to=get_image_path, blank=True, null=True, max_length=255, +        help_text=max_size_help())      index = models.IntegerField(verbose_name=_(u"Index"), blank=True,                                  null=True)      external_id = models.TextField(_(u"External ID"), null=True, blank=True) diff --git a/ishtar_common/models_imports.py b/ishtar_common/models_imports.py index b5ce3323d..e9f0e5d9e 100644 --- a/ishtar_common/models_imports.py +++ b/ishtar_common/models_imports.py @@ -41,7 +41,7 @@ from django.utils.translation import ugettext_lazy as _, pgettext_lazy  from ishtar_common.utils import create_slug, \      get_all_related_m2m_objects_with_model, put_session_message, \ -    put_session_var, get_session_var, num2col +    put_session_var, get_session_var, num2col, max_size_help  from ishtar_common.data_importer import Importer, ImportFormater, \      IntegerFormater, FloatFormater, UnicodeFormater, DateFormater, \      TypeFormater, YearFormater, StrToBoolean, FileFormater, InseeFormater, \ @@ -828,10 +828,11 @@ class Import(models.Model):      name = models.CharField(_(u"Name"), max_length=500, null=True)      importer_type = models.ForeignKey(ImporterType)      imported_file = models.FileField( -        _(u"Imported file"), upload_to="upload/imports/%Y/%m/", max_length=220) +        _(u"Imported file"), upload_to="upload/imports/%Y/%m/", max_length=220, +        help_text=max_size_help())      imported_images = models.FileField(          _(u"Associated images (zip file)"), upload_to="upload/imports/%Y/%m/", -        blank=True, null=True, max_length=220) +        blank=True, null=True, max_length=220, help_text=max_size_help())      associated_group = models.ForeignKey(          TargetKeyGroup, blank=True, null=True,          help_text=_(u"If a group is selected, target key saved in this group " @@ -842,15 +843,15 @@ class Import(models.Model):      skip_lines = models.IntegerField(          _(u"Skip lines"), default=1,          help_text=_(u"Number of header lines in your file (can be 0).")) -    error_file = models.FileField(_(u"Error file"), -                                  upload_to="upload/imports/%Y/%m/", -                                  blank=True, null=True, max_length=255) -    result_file = models.FileField(_(u"Result file"), -                                   upload_to="upload/imports/%Y/%m/", -                                   blank=True, null=True, max_length=255) -    match_file = models.FileField(_(u"Match file"), -                                  upload_to="upload/imports/%Y/%m/", -                                  blank=True, null=True, max_length=255) +    error_file = models.FileField( +        _(u"Error file"), upload_to="upload/imports/%Y/%m/", +        blank=True, null=True, max_length=255, help_text=max_size_help()) +    result_file = models.FileField( +        _(u"Result file"), upload_to="upload/imports/%Y/%m/", +        blank=True, null=True, max_length=255, help_text=max_size_help()) +    match_file = models.FileField( +        _(u"Match file"), upload_to="upload/imports/%Y/%m/", blank=True, +        null=True, max_length=255, help_text=max_size_help())      state = models.CharField(_(u"State"), max_length=2, choices=IMPORT_STATE,                               default=u'C')      conservative_import = models.BooleanField( diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index cbc7d069d..562992bdb 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -958,3 +958,10 @@ def m2m_historization_changed(sender, **kwargs):      elif not obj.history_modifier:          obj.skip_history_when_saving = True      obj.save() + + +def max_size_help(): +    msg = unicode(_(u"The maximum supported file size is {} Mo.")).format( +        settings.MAX_UPLOAD_SIZE +    ) +    return msg | 
