Skip to content

Commit

Permalink
Merge branch 'main' into add_getobjsize_info_in_serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
cekk authored Mar 1, 2024
2 parents a3d0279 + 96a9e8a commit 6d140fc
Show file tree
Hide file tree
Showing 20 changed files with 324 additions and 48 deletions.
40 changes: 39 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,40 @@
Changelog
=========

6.1.11 (unreleased)
6.1.15 (unreleased)
-------------------

- Nothing changed yet.


6.1.14 (2024-02-20)
-------------------

- Fix in @scadenziario endpoint: return future events if afterToday criteria is set.
[cekk]
- Set base view to News Item, to do not break on Classic Plone.
[cekk]
- Change description for field sede in UnitaOrganizzativa CT.
- Fixed typo in update_note field description.
[eikichi18]



6.1.13 (2024-02-08)
-------------------

- Handle missing `show_dynamic_folders_in_footer` in registry entry.
[cekk]


6.1.12 (2024-02-06)
-------------------

- Remove un-needed commit in upgrade-step.
[cekk]


6.1.11 (2024-01-29)
-------------------

- Added new indexer, catalog index and query operation for canale_digitale_link field of Servizio CT
Expand All @@ -13,6 +46,11 @@ Changelog
[cekk]
- Add enhancedlinks infos in File field serializer.
[cekk]
- Add new flag in settings needed to choose to show or not auto-generated footer columns.
[cekk]
- Customize @navigation endpoint to expose also the new flag for frontend.
[cekk]


6.1.10 (2024-01-16)
-------------------
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

- [Design Plone Content-types](#design-plone-content-types)
- [Features](#features)
- [Compatibilità](#compatibilit%C3%A0)
- [Compatibilità](#compatibilità)
- [Tipi di contenuto](#tipi-di-contenuto)
- [Elenco tipi implementati](#elenco-tipi-implementati)
- [Bando](#bando)
Expand All @@ -30,10 +30,11 @@
- [Campi indicizzati nel SearchableText](#campi-indicizzati-nel-searchabletext-2)
- [Servizio](#servizio)
- [Campi indicizzati nel SearchableText](#campi-indicizzati-nel-searchabletext-3)
- [Unità Organizzativa](#unit%C3%A0-organizzativa)
- [Unità Organizzativa](#unità-organizzativa)
- [Campi indicizzati nel SearchableText](#campi-indicizzati-nel-searchabletext-4)
- [Pannello di controllo](#pannello-di-controllo)
- [Gestione modulistica](#gestione-modulistica)
- [Viste verifica contentuti](#viste-verifica-contentuti)
- [Data di modifica](#data-di-modifica)
- [Endpoint restapi](#endpoint-restapi)
- [Customizzazione dati relation field](#customizzazione-dati-relation-field)
Expand Down Expand Up @@ -421,6 +422,10 @@ Endpoint ed expansion per la modulistica.
Nei content-type CartellaModulistica, tra i vari expansion c'è anche `@modulistica_items`.
Questo è utile per la vista di frontend, in quanto se richiamato, ritorna la struttura di dati da mostrare in visualizzazione.

## @navigation

Endpoint customizzato da plone.restapi per esporre anche il valore show_in_footer per decidere se disegnare o meno le colonne dinamiche nel footer.

# Installazione

Questo prodotto non è stato pensato per funzionare da solo, ma fa parte della suite "design.plone".
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

setup(
name="design.plone.contenttypes",
version="6.1.11.dev0",
version="6.1.15.dev0",
description="DesignItalia contenty types",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
2 changes: 1 addition & 1 deletion src/design/plone/contenttypes/behaviors/update_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class IUpdateNote(model.Schema):
description=_(
"help_update_note",
default="Inserisci una nota per indicare che il contenuto corrente è stato aggiornato." # noqa
"Questo testo può essere visualizzato nei blocchi elenco con determinati layout per informare " # noqa
" Questo testo può essere visualizzato nei blocchi elenco con determinati layout per informare " # noqa
"gli utenti che un determinato contenuto è stato aggiornato. "
"Ad esempio se in un bando sono stati aggiunti dei documenti.",
),
Expand Down

This file was deleted.

10 changes: 10 additions & 0 deletions src/design/plone/contenttypes/controlpanels/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ class IDesignPloneSettings(Interface):
default=True,
required=False,
)
show_dynamic_folders_in_footer = Bool(
title=_("show_dynamic_folders_in_footer_label", default="Footer dinamico"),
description=_(
"show_dynamic_folders_in_footer_help",
default="Se selezionato, il footer verrà popolato automaticamente "
"con i contenuti di primo livello non esclusi dalla navigazione.",
),
default=True,
required=False,
)


class DesignPloneControlPanelForm(RegistryEditForm):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,8 @@ class IUnitaOrganizzativa(model.Schema, IDesignPloneContentType):
description=_(
"sede_help",
default="Seleziona il Luogo in cui questa struttura ha sede. "
"Se non è presente un contenuto di tipo Luogo a cui far "
"riferimento, puoi compilare i campi seguenti. Se selezioni un "
"Luogo, puoi usare comunque i campi seguenti per sovrascrivere "
"alcune informazioni.",
"Se non è presente creare il Luogo nella sezione dedicata "
"nell'alberatura del sito.",
),
value_type=RelationChoice(
title=_("Sede"), vocabulary="plone.app.vocabularies.Catalog"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<version>7030</version>
<version>7040</version>
<dependencies>
<dependency>profile-redturtle.bandi:default</dependency>
<dependency>profile-collective.venue:default</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
name="Document"
i18n:domain="plone"
>

<property name="behaviors"
purge="False"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<element value="File" />

</property>

<property name="behaviors"
purge="False"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<element value="File" />
</property>

<property name="default_view">view</property>
<property name="view_methods">
<element value="view" />
</property>

<property name="behaviors"
purge="False"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

<include package=".content" />
<include package=".modulistica_items" />
<include package=".navigation" />
<include package=".types" />
<include package=".scadenziario" />
<include package=".trasparenza" />
<include package=".scadenziario" />


<adapter
factory=".controlpanel.DesignPloneSettings"
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:cache="http://namespaces.zope.org/cache"
xmlns:plone="http://namespaces.plone.org/plone"
xmlns:zcml="http://namespaces.zope.org/zcml"
>

<adapter
factory=".get.Navigation"
name="navigation"
/>

<plone:service
method="GET"
factory=".get.NavigationGet"
for="zope.interface.Interface"
permission="zope2.View"
layer="design.plone.contenttypes.interfaces.IDesignPloneContenttypesLayer"
name="@navigation"
/>

</configure>
32 changes: 32 additions & 0 deletions src/design/plone/contenttypes/restapi/services/navigation/get.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from design.plone.contenttypes.controlpanels.settings import IDesignPloneSettings
from design.plone.contenttypes.interfaces import IDesignPloneContenttypesLayer
from plone import api
from plone.restapi.interfaces import IExpandableElement
from plone.restapi.services import Service
from plone.restapi.services.navigation.get import Navigation as BaseNavigation
from zope.component import adapter
from zope.interface import implementer
from zope.interface import Interface


@implementer(IExpandableElement)
@adapter(Interface, IDesignPloneContenttypesLayer)
class Navigation(BaseNavigation):
def __call__(self, expand=False):
result = super().__call__(expand=expand)
try:
show_dynamic_folders_in_footer = api.portal.get_registry_record(
"show_dynamic_folders_in_footer",
interface=IDesignPloneSettings,
default=True,
)
except KeyError:
show_dynamic_folders_in_footer = True
result["navigation"]["show_in_footer"] = show_dynamic_folders_in_footer
return result


class NavigationGet(Service):
def reply(self):
navigation = Navigation(self.context, self.request)
return navigation(expand=True)["navigation"]
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,13 @@ def reply(self):
if "start" in query_for_catalog:
start = query_for_catalog["start"]["query"]
if "end" in query_for_catalog:
end = query_for_catalog["end"]["query"]
if query_for_catalog["end"].get("range", "") != "min":
# per esempio, è impostato il filtro "con fine evento da domani".
# se impostiamo un'end (la data di domani), poi nella generazione delle ricorrenze,
# vengono scartati tutti gli eventi che hanno una data di inizio nel futuro
# (https://github.com/plone/plone.event/blob/master/plone/event/recurrence.py#L141)
# perché la data della ricorrenza è maggiore di "until", che è quello che qui inviamo come end.
end = query_for_catalog["end"]["query"]
expanded_events = self.expand_events(events, 3, start, end)

all_results = not_events + expanded_events
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# -*- coding: utf-8 -*-
from design.plone.contenttypes.controlpanels.settings import IDesignPloneSettings
from design.plone.contenttypes.testing import (
DESIGN_PLONE_CONTENTTYPES_API_FUNCTIONAL_TESTING,
)
from plone import api
from plone.app.testing import setRoles
from plone.app.testing import SITE_OWNER_NAME
from plone.app.testing import SITE_OWNER_PASSWORD
from plone.app.testing import TEST_USER_ID
from plone.dexterity.utils import createContentInContainer
from plone.restapi.testing import RelativeSession
from transaction import commit

import unittest


class CustomNavigationTest(unittest.TestCase):
layer = DESIGN_PLONE_CONTENTTYPES_API_FUNCTIONAL_TESTING

def setUp(self):
self.app = self.layer["app"]
self.portal = self.layer["portal"]
self.portal_url = self.portal.absolute_url()
self.api_session = RelativeSession(self.portal_url)
self.api_session.headers.update({"Accept": "application/json"})
self.api_session.auth = (SITE_OWNER_NAME, SITE_OWNER_PASSWORD)
setRoles(self.portal, TEST_USER_ID, ["Manager"])

self.folder = createContentInContainer(
self.portal, "Folder", id="folder", title="Some Folder"
)
self.folder2 = createContentInContainer(
self.portal, "Folder", id="folder2", title="Some Folder 2"
)
self.subfolder1 = createContentInContainer(
self.folder, "Folder", id="subfolder1", title="SubFolder 1"
)
self.subfolder2 = createContentInContainer(
self.folder, "Folder", id="subfolder2", title="SubFolder 2"
)
self.thirdlevelfolder = createContentInContainer(
self.subfolder1,
"Folder",
id="thirdlevelfolder",
title="Third Level Folder",
)
self.fourthlevelfolder = createContentInContainer(
self.thirdlevelfolder,
"Folder",
id="fourthlevelfolder",
title="Fourth Level Folder",
)
createContentInContainer(self.folder, "Document", id="doc1", title="A document")
commit()

def tearDown(self):
self.api_session.close()

def test_return_show_in_footer_info_based_on_registry(self):
# by default is True
response = self.api_session.get(
"/@navigation", params={"expand.navigation.depth": 2}
).json()

self.assertIn("show_in_footer", response)
self.assertTrue(response["show_in_footer"])

# change it
api.portal.set_registry_record(
"show_dynamic_folders_in_footer",
False,
interface=IDesignPloneSettings,
)
commit()

response = self.api_session.get(
"/@navigation", params={"expand.navigation.depth": 2}
).json()

self.assertIn("show_in_footer", response)
self.assertFalse(response["show_in_footer"])
Loading

0 comments on commit 6d140fc

Please sign in to comment.