diff --git a/src/iosanita/policy/interfaces.py b/src/iosanita/policy/interfaces.py
index a083340..23894f5 100644
--- a/src/iosanita/policy/interfaces.py
+++ b/src/iosanita/policy/interfaces.py
@@ -53,6 +53,18 @@ class IIoSanitaSettings(Interface):
required=False,
)
+ quick_search_sections = SourceText(
+ title=_(
+ "quick_search_sections_label", default="Percorsi per la ricerca rapida"
+ ),
+ description=_(
+ "search_sections_help",
+ default="Inserire una lista di sezioni per la ricerca rapida.",
+ ),
+ default="",
+ required=False,
+ )
+
show_modified_default = Bool(
title=_("show_modified_default_label", default="Mostra la data di modifica"),
description=_(
diff --git a/src/iosanita/policy/restapi/services/configure.zcml b/src/iosanita/policy/restapi/services/configure.zcml
index 3cb15f6..e1e4f9c 100644
--- a/src/iosanita/policy/restapi/services/configure.zcml
+++ b/src/iosanita/policy/restapi/services/configure.zcml
@@ -5,5 +5,7 @@
>
+
+
diff --git a/src/iosanita/policy/restapi/services/search_filters/__init__.py b/src/iosanita/policy/restapi/services/search_filters/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/src/iosanita/policy/restapi/services/search_filters/configure.zcml b/src/iosanita/policy/restapi/services/search_filters/configure.zcml
new file mode 100644
index 0000000..b94cd3f
--- /dev/null
+++ b/src/iosanita/policy/restapi/services/search_filters/configure.zcml
@@ -0,0 +1,16 @@
+
+
+
+
+
diff --git a/src/iosanita/policy/restapi/services/search_filters/get.py b/src/iosanita/policy/restapi/services/search_filters/get.py
new file mode 100644
index 0000000..e06ac86
--- /dev/null
+++ b/src/iosanita/policy/restapi/services/search_filters/get.py
@@ -0,0 +1,66 @@
+# -*- coding: utf-8 -*-
+from iosanita.policy import _
+from plone import api
+from plone.restapi.interfaces import ISerializeToJsonSummary
+from plone.restapi.services import Service
+from zope.component import getMultiAdapter
+from iosanita.policy.interfaces import IIoSanitaSettings
+from AccessControl.unauthorized import Unauthorized
+
+import json
+
+
+class SearchFiltersGET(Service):
+ def reply(self):
+ return {
+ "sections": self.get_section_data(field_id="search_sections"),
+ "quick_search_sections": self.get_section_data(
+ field_id="quick_search_sections"
+ ),
+ }
+
+ def get_section_data(self, field_id):
+ try:
+ values = api.portal.get_registry_record(
+ field_id, interface=IIoSanitaSettings, default="[]"
+ )
+ except KeyError:
+ return []
+ utils = api.portal.get_tool(name="plone_utils")
+
+ sections = []
+ for setting in json.loads(values or "[]"):
+ items = []
+ for section_settings in setting.get("items") or []:
+ for uid in section_settings.get("linkUrl") or []:
+ try:
+ section = api.content.get(UID=uid)
+ except Unauthorized:
+ # private folder
+ continue
+ if not section:
+ continue
+ item_infos = getMultiAdapter(
+ (section, self.request),
+ ISerializeToJsonSummary,
+ )()
+ children = section.listFolderContents(
+ contentFilter={"portal_type": utils.getUserFriendlyTypes()}
+ )
+ item_infos["items"] = [
+ getMultiAdapter(
+ (x, self.request),
+ ISerializeToJsonSummary,
+ )()
+ for x in children
+ ]
+ item_infos["title"] = section_settings.get("title", "")
+ items.append(item_infos)
+ if items:
+ sections.append(
+ {
+ "rootPath": setting.get("rootPath", ""),
+ "items": items,
+ }
+ )
+ return sections