diff --git a/src/openforms/config/migrations/0059_alter_globalconfiguration_form_upload_default_file_types.py b/src/openforms/config/migrations/0059_alter_globalconfiguration_form_upload_default_file_types.py index 6275c11976..0a49a892c0 100644 --- a/src/openforms/config/migrations/0059_alter_globalconfiguration_form_upload_default_file_types.py +++ b/src/openforms/config/migrations/0059_alter_globalconfiguration_form_upload_default_file_types.py @@ -4,6 +4,27 @@ import django_jsonform.models.fields +from openforms.config.constants import UploadFileType + + +def add_extra_zip_mimetypes(apps, _): + """ + Set up the correct zip mimetypes. + + This ensures all the allowed mimetypes concerning zip files are included. + """ + GlobalConfiguration = apps.get_model("config", "GlobalConfiguration") + if not GlobalConfiguration.objects.exists(): + return + + config = GlobalConfiguration.objects.get() + if "application/zip" not in config.form_upload_default_file_types: + return + + config.form_upload_default_file_types.remove("application/zip") + config.form_upload_default_file_types.append(UploadFileType.zip) + config.save(update_fields=("form_upload_default_file_types",)) + class Migration(migrations.Migration): @@ -60,4 +81,8 @@ class Migration(migrations.Migration): verbose_name="Default allowed file upload types", ), ), + migrations.RunPython( + add_extra_zip_mimetypes, + migrations.RunPython.noop, + ), ]