diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index a3469b9..60e7104 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -3,8 +3,8 @@ name: Tests
on:
push:
paths-ignore:
- - '**.md'
- - '**.rst'
+ - "**.md"
+ - "**.rst"
jobs:
build:
runs-on: ubuntu-latest
@@ -16,7 +16,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Cache eggs
- uses: actions/cache@v3
+ uses: actions/cache@v4
with:
path: eggs
key: ${{ runner.OS }}-build-python${{ matrix.python }}-${{ matrix.plone }}
diff --git a/CHANGES.rst b/CHANGES.rst
index f402fbe..7b58fdb 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -5,6 +5,8 @@ Changelog
1.0.8 (unreleased)
------------------
+- Add Bando serializer to return bando_state and approfondimento.
+ [cekk]
- Blocco search / variante table - aggiunte le proprietà dei campi nella colonna nel serializer
[mamico]
- get_taxonomy_vocab non si rompe se non è presente la tassonomia richiesta.
diff --git a/setup.cfg b/setup.cfg
index bd9250c..c726a5e 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -15,17 +15,10 @@ line_length = 200
not_skip = __init__.py
[flake8]
-# black compatible flake8 rules:
-ignore =
- W503,
- C812,
- E501
- T001
- C813
-# E203, E266
exclude = bootstrap.py,docs,*.egg.,omelette
-max-line-length = 88
-max-complexity = 18
-select = B,C,E,F,W,T4,B9
-builtins = unicode,basestring
-
+max-complexity = 15
+max-line-length = 100000
+extend-ignore =
+ E203,
+ C901,
+ C101
diff --git a/src/iosanita/contenttypes/restapi/serializers/bando.py b/src/iosanita/contenttypes/restapi/serializers/bando.py
new file mode 100644
index 0000000..33949fe
--- /dev/null
+++ b/src/iosanita/contenttypes/restapi/serializers/bando.py
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+from plone.restapi.interfaces import ISerializeToJson
+from plone.restapi.serializer.dxcontent import SerializeFolderToJson
+from redturtle.bandi.interfaces.bandoSchema import IBandoSchema
+from zope.component import adapter
+from zope.interface import implementer
+from zope.interface import Interface
+
+
+@implementer(ISerializeToJson)
+@adapter(IBandoSchema, Interface)
+class BandoSerializeToJson(SerializeFolderToJson):
+ def get_approfondimenti(self, bando_view):
+ """ """
+ folders = bando_view.retrieveFolderDeepening()
+ results = []
+
+ for folder in folders:
+ contents = bando_view.retrieveContentsOfFolderDeepening(folder["path"])
+ if not contents:
+ continue
+ # fix results for enhancedlinks
+ for content in contents:
+ content["getObjSize"] = content.get("filesize", "")
+ content["mime_type"] = content.get("content-type", "")
+ content["enhanced_links_enabled"] = "filesize" in content
+ folder.update({"children": contents})
+ results.append(folder)
+ return results
+
+ def __call__(self, version=None, include_items=True):
+ result = super().__call__(version=version, include_items=include_items)
+ bando_view = self.context.restrictedTraverse("bando_view")
+ result["approfondimento"] = self.get_approfondimenti(bando_view)
+ result["bando_state"] = bando_view.getBandoState()
+ return result
diff --git a/src/iosanita/contenttypes/restapi/serializers/configure.zcml b/src/iosanita/contenttypes/restapi/serializers/configure.zcml
index 4f63fa0..1adb158 100644
--- a/src/iosanita/contenttypes/restapi/serializers/configure.zcml
+++ b/src/iosanita/contenttypes/restapi/serializers/configure.zcml
@@ -2,7 +2,7 @@
xmlns="http://namespaces.zope.org/zope"
xmlns:zcml="http://namespaces.zope.org/zcml"
>
-
+