From 9cc2b87099528de6d4f1a7d7603ccf046e4fbd71 Mon Sep 17 00:00:00 2001 From: Andrea Cecchi Date: Thu, 27 Jun 2024 17:14:12 +0200 Subject: [PATCH] =?UTF-8?q?Set=20=20field=20as=20primary,=20so=20we=20call?= =?UTF-8?q?=20@@download=20on=20the=20content,=20that=20fil=E2=80=A6=20(#2?= =?UTF-8?q?68)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGES.rst | 3 ++- src/design/plone/contenttypes/behaviors/multi_file.py | 2 ++ .../plone/contenttypes/restapi/serializers/dxcontent.py | 1 - src/design/plone/contenttypes/upgrades/to_730x.py | 6 +++++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index bc91a3a5..e422efc6 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,7 +4,8 @@ Changelog 6.2.13 (unreleased) ------------------- -- Nothing changed yet. +- Set `file_principale` field as primary, so we call @@download on the content, that file will be downloaded automatically. + [cekk] 6.2.12 (2024-06-24) diff --git a/src/design/plone/contenttypes/behaviors/multi_file.py b/src/design/plone/contenttypes/behaviors/multi_file.py index 11e306b4..90dbc1fa 100644 --- a/src/design/plone/contenttypes/behaviors/multi_file.py +++ b/src/design/plone/contenttypes/behaviors/multi_file.py @@ -41,6 +41,8 @@ class IMultiFileSchema(model.Schema): required=False, ) + model.primary("file_principale") + @provider(IFormFieldProvider) class IMultiFile(IMultiFileSchema): diff --git a/src/design/plone/contenttypes/restapi/serializers/dxcontent.py b/src/design/plone/contenttypes/restapi/serializers/dxcontent.py index a87880c6..568cc3a3 100644 --- a/src/design/plone/contenttypes/restapi/serializers/dxcontent.py +++ b/src/design/plone/contenttypes/restapi/serializers/dxcontent.py @@ -51,7 +51,6 @@ def __call__(self, version=None, include_items=True): @adapter(IDexterityContainer, IDesignPloneContenttypesLayer) class SerializeFolderToJson(BaseFolderSerializer, MetaTypeSerializer): def __call__(self, version=None, include_items=True): - result = super(SerializeFolderToJson, self).__call__( version=version, include_items=include_items ) diff --git a/src/design/plone/contenttypes/upgrades/to_730x.py b/src/design/plone/contenttypes/upgrades/to_730x.py index 5ec2ca47..5d5dcf3a 100644 --- a/src/design/plone/contenttypes/upgrades/to_730x.py +++ b/src/design/plone/contenttypes/upgrades/to_730x.py @@ -96,7 +96,11 @@ def to_7304(context): def to_7305(context): mapping = SUBFOLDERS_MAPPING["Servizio"] - mapping = [folder for folder in mapping.get('content') if folder["id"] == "modulistica"][0] # noqa + mapping = [ + folder for folder in mapping.get("content") if folder["id"] == "modulistica" + ][ + 0 + ] # noqa brains = api.content.find(portal_type="Servizio") tot = len(brains) i = 0