Skip to content

Commit

Permalink
[#4701] Added missing data migration for the global config and zip mi…
Browse files Browse the repository at this point in the history
…metypes

(cherry picked from commit d8d3b4a)
  • Loading branch information
vaszig authored and sergei-maertens committed Sep 24, 2024
1 parent 7985a07 commit c49d382
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down Expand Up @@ -60,4 +81,8 @@ class Migration(migrations.Migration):
verbose_name="Default allowed file upload types",
),
),
migrations.RunPython(
add_extra_zip_mimetypes,
migrations.RunPython.noop,
),
]

0 comments on commit c49d382

Please sign in to comment.