diff --git a/Dockerfile b/Dockerfile index 6bdb59f843..009785c757 100644 --- a/Dockerfile +++ b/Dockerfile @@ -92,6 +92,7 @@ COPY \ ./bin/report_component_problems.py \ ./bin/check_objecttype_urls.py \ ./bin/check_zgw_groups.py \ + ./bin/fix_globalconfig_zip.py \ ./bin/ # prevent writing to the container layer, which would degrade performance. diff --git a/bin/fix_globalconfig_zip.py b/bin/fix_globalconfig_zip.py new file mode 100755 index 0000000000..1a6bad0bc3 --- /dev/null +++ b/bin/fix_globalconfig_zip.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python +import sys +from pathlib import Path + +import django + +SRC_DIR = Path(__file__).parent.parent / "src" +sys.path.insert(0, str(SRC_DIR.resolve())) + + +def main() -> None: + from openforms.setup import setup_env + + setup_env() + django.setup() + + from openforms.config.constants import UploadFileType + from openforms.config.models import GlobalConfiguration + + config = GlobalConfiguration.get_solo() + 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",)) + + +if __name__ == "__main__": + main()