Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: Tests
on:
push:
paths-ignore:
- '**.md'
- '**.rst'
- "**.md"
- "**.rst"
jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -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 }}
Expand Down
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 6 additions & 13 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
36 changes: 36 additions & 0 deletions src/iosanita/contenttypes/restapi/serializers/bando.py
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
xmlns="http://namespaces.zope.org/zope"
xmlns:zcml="http://namespaces.zope.org/zcml"
>

<adapter factory=".bando.BandoSerializeToJson" />
<adapter factory=".news.NewsItemSerializeToJson" />
<adapter factory=".summary.IOSanitaJSONSummarySerializer" />
<adapter factory=".summary.PuntoDiContattoJSONSummarySerializer" />
Expand Down