diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-02-22 13:35:45 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-02-28 12:15:24 +0100 |
commit | 9d0bb012a463c7ce7805efd25888f938bb7d8867 (patch) | |
tree | 5681d0db3a55428e21f42696827942aa6aca8d34 | |
parent | 66b696717c21c46a14aa83636e655a9bfbbdb362 (diff) | |
download | Ishtar-9d0bb012a463c7ce7805efd25888f938bb7d8867.tar.bz2 Ishtar-9d0bb012a463c7ce7805efd25888f938bb7d8867.zip |
Imports: imported file not mandatory (when zipped can be null) - do not raise error if media file is missing
-rw-r--r-- | archaeological_finds/tests/notices-panier.odt | bin | 0 -> 55063 bytes | |||
-rw-r--r-- | ishtar_common/migrations/0212_auto_20210222_1334.py (renamed from ishtar_common/migrations/0212_auto_20210219_1408.py) | 7 | ||||
-rw-r--r-- | ishtar_common/models_imports.py | 7 |
3 files changed, 11 insertions, 3 deletions
diff --git a/archaeological_finds/tests/notices-panier.odt b/archaeological_finds/tests/notices-panier.odt Binary files differnew file mode 100644 index 000000000..71b248e79 --- /dev/null +++ b/archaeological_finds/tests/notices-panier.odt diff --git a/ishtar_common/migrations/0212_auto_20210219_1408.py b/ishtar_common/migrations/0212_auto_20210222_1334.py index 25d49e75f..703b58f2b 100644 --- a/ishtar_common/migrations/0212_auto_20210219_1408.py +++ b/ishtar_common/migrations/0212_auto_20210222_1334.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.11.27 on 2021-02-19 14:08 +# Generated by Django 1.11.27 on 2021-02-22 13:34 from __future__ import unicode_literals from django.db import migrations, models @@ -29,6 +29,11 @@ class Migration(migrations.Migration): field=models.CharField(blank=True, choices=[('M', 'Male'), ('F', 'Female'), ('N', 'Neutral')], default='', help_text=ishtar_common.models.documentation_get_gender_values, max_length=1, verbose_name='Grammatical gender'), ), migrations.AlterField( + model_name='import', + name='imported_file', + field=models.FileField(blank=True, help_text='La taille maximale supportée pour le fichier est de 100 Mo.', max_length=220, null=True, upload_to='upload/imports/%Y/%m/', verbose_name='Imported file'), + ), + migrations.AlterField( model_name='organization', name='grammatical_gender', field=models.CharField(blank=True, choices=[('M', 'Male'), ('F', 'Female'), ('N', 'Neutral')], default='', help_text=ishtar_common.models.documentation_get_gender_values, max_length=1, verbose_name='Grammatical gender'), diff --git a/ishtar_common/models_imports.py b/ishtar_common/models_imports.py index 5a3af1a05..7462f55be 100644 --- a/ishtar_common/models_imports.py +++ b/ishtar_common/models_imports.py @@ -939,7 +939,7 @@ class Import(models.Model): importer_type = models.ForeignKey(ImporterType) imported_file = models.FileField( _("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) imported_images = models.FileField( _("Associated images (zip file)"), upload_to="upload/imports/%Y/%m/", blank=True, null=True, max_length=220, help_text=max_size_help()) @@ -1438,7 +1438,10 @@ class Import(models.Model): for attr in file_attr: file_field = getattr(self, attr) if file_field: - os.remove(file_field.path) + try: + os.remove(file_field.path) + except FileNotFoundError: + pass setattr(self, attr, None) self.save() self._archive_pending = False |