diff --git a/news/URB-2596.feature b/news/URB-2596.feature
new file mode 100644
index 000000000..1ff15f2c9
--- /dev/null
+++ b/news/URB-2596.feature
@@ -0,0 +1,2 @@
+Add a reference index and integrate the reference fields into the faceted search.
+[WBoudabous]
\ No newline at end of file
diff --git a/src/Products/urban/dashboard/config/all.xml b/src/Products/urban/dashboard/config/all.xml
index aa8012a83..d7a30bd70 100644
--- a/src/Products/urban/dashboard/config/all.xml
+++ b/src/Products/urban/dashboard/config/all.xml
@@ -1,149 +1,172 @@
+
+
+ sorting
+ Tri
+ top
+ default
+ True
+ eea.faceted.vocabularies.SortingCatalogIndexes
+ created(reverse)
+
+
+ collection-link
+ Procédures
+ top
+ default
+ True
+
+
+
+ collective.eeafaceted.collectionwidget.cachedcollectionvocabulary
+ True
+ True
+
+ 12ffe12f7dc04b3ba4e82906b83abfbc
+
+
+ text
+ Demandeur
+ top
+ advanced
+ False
+ applicantInfosIndex
+
+ True
+ True
+
+
+ autocomplete
+ Rue
+ top
+ advanced
+ False
+ StreetsUID
+
+ sreets-autocomplete-suggest
+ True
+
+
+ text
+ N° de police
+ top
+ advanced
+ False
+ StreetNumber
+
+ True
+
+
+
+ autocomplete
+ Référence cadastrale
+ top
+ advanced
+ False
+ parcelInfosIndex
+
+ cadastral-autocomplete-suggest
+ True
+
+
+ daterange
+ Date de décision
+ top
+ advanced
+ False
+ getDecisionDate
+
+ c-10:c+10
+
+
+ daterange
+ Date de validité
+ top
+ advanced
+ False
+ getValidityDate
+
+ c-10:c+10
+
+
+ text
+ Titre, référence
+ center
+ default
+ False
+ Title
+
+ True
+ True
+
+
+ select
+ Agent traitant
+ center
+ default
+ False
+
+
+
+ folder_manager
+ urban.folder_managers
+
+
+
+
+
+ select_to_list
+ Type
+ center
+ default
+ False
+
+
+
+ portal_type
+ urban.vocabularies.procedure_category
+
+
+ codt
+
+
+ resultsperpage
+ Results per page
+ center
+ default
+ False
+ 0
+ 50
+ 10
+ 20
+
+
+ text
+ Référence FT (ARNE)"
+ center
+ default
+ False
+ getReferenceFT
+
+ True
+ True
+
+
+ text
+ Référence FD (TLPE)"
+ top
+ advanced
+ False
+ getReferenceDgatlp
+
+ True
+ True
+
+
+
+
\ No newline at end of file
diff --git a/src/Products/urban/dashboard/config/codt_buildlicences.xml b/src/Products/urban/dashboard/config/codt_buildlicences.xml
index 7eecf0360..bf62ca771 100644
--- a/src/Products/urban/dashboard/config/codt_buildlicences.xml
+++ b/src/Products/urban/dashboard/config/codt_buildlicences.xml
@@ -1,183 +1,205 @@
+
+
+ sorting
+ Tri
+ top
+ default
+ True
+ eea.faceted.vocabularies.SortingCatalogIndexes
+ created(reverse)
+
+
+ collection-link
+ Procédures
+ top
+ default
+ True
+
+
+
+ collective.eeafaceted.collectionwidget.cachedcollectionvocabulary
+ True
+ True
+
+ b0efd11e10b041d4b4f5141322a8a488
+
+
+ daterange
+ Date de la décision
+ top
+ advanced
+ False
+ getDecisionDate
+
+ c-10:c+10
+
+
+ daterange
+ Date de validité
+ top
+ advanced
+ False
+ getValidityDate
+
+ c-10:c+10
+
+
+ text
+ Demandeur
+ top
+ advanced
+ False
+ applicantInfosIndex
+
+ True
+ True
+
+
+ autocomplete
+ Architecte
+ top
+ advanced
+ False
+ representatives
+
+ architects-autocomplete-suggest
+ True
+
+
+ autocomplete
+ Rue
+ top
+ advanced
+ False
+ StreetsUID
+
+ sreets-autocomplete-suggest
+ True
+
+
+ text
+ N° de police
+ top
+ advanced
+ False
+ StreetNumber
+
+ True
+
+
+
+ autocomplete
+ Référence cadastrale
+ top
+ advanced
+ False
+ parcelInfosIndex
+
+ cadastral-autocomplete-suggest
+ True
+
+
+ daterangecustom
+ Date d'enquête
+ top
+ advanced
+ False
+ investigationStart
+
+ c-10:c+10
+ investigationEnd
+
+
+ text
+ Référence supplémentaire
+ top
+ advanced
+ False
+ getAdditionalReference
+
+ True
+ True
+
+
+ text
+ Titre, référence
+ center
+ default
+ False
+ Title
+
+ True
+ True
+
+
+ select
+ Agent traitant
+ center
+ default
+ False
+
+
+
+ folder_manager
+ urban.folder_managers
+
+
+
+
+
+ checkbox
+ État
+ center
+ default
+ False
+ 0
+ 0
+ 0
+ review_state
+ or
+ 0
+ urban.rootfolder_licence_state
+
+ 0
+
+
+ resultsperpage
+ Results per page
+ center
+ default
+ False
+ 0
+ 50
+ 10
+ 20
+
+
+ text
+ Référence FD (TLPE)"
+ top
+ advanced
+ False
+ getReferenceDgatlp
+
+ True
+ True
+
+
+ text
+ Référence FT (ARNE)"
+ center
+ default
+ False
+ getReferenceFT
+
+ True
+ True
+
+
+
\ No newline at end of file
diff --git a/src/Products/urban/dashboard/config/codt_notaryletters.xml b/src/Products/urban/dashboard/config/codt_notaryletters.xml
index cd9007ba7..e87ec93a8 100644
--- a/src/Products/urban/dashboard/config/codt_notaryletters.xml
+++ b/src/Products/urban/dashboard/config/codt_notaryletters.xml
@@ -1,161 +1,161 @@
+
+
+ sorting
+ Tri
+ top
+ default
+ True
+ eea.faceted.vocabularies.SortingCatalogIndexes
+ created(reverse)
+
+
+ collection-link
+ Procédures
+ top
+ default
+ True
+
+
+
+ collective.eeafaceted.collectionwidget.cachedcollectionvocabulary
+ True
+ True
+
+ 1d9a2c1805894e6d8217ff073c253b75
+
+
+ text
+ Demandeur
+ top
+ advanced
+ False
+ applicantInfosIndex
+
+ True
+ True
+
+
+ daterange
+ Date de validité
+ top
+ advanced
+ False
+ getValidityDate
+
+ c-10:c+10
+
+
+ autocomplete
+ Notaire
+ top
+ advanced
+ False
+ representatives
+
+ notaries-autocomplete-suggest
+ True
+
+
+ autocomplete
+ Rue
+ top
+ advanced
+ False
+ StreetsUID
+
+ sreets-autocomplete-suggest
+ True
+
+
+ text
+ N° de police
+ top
+ advanced
+ False
+ StreetNumber
+
+ True
+
+
+
+ autocomplete
+ Référence cadastrale
+ top
+ advanced
+ False
+ parcelInfosIndex
+
+ cadastral-autocomplete-suggest
+ True
+
+
+ text
+ Référence supplémentaire
+ top
+ advanced
+ False
+ getAdditionalReference
+
+ True
+ True
+
+
+ text
+ Titre, référence
+ center
+ default
+ False
+ Title
+
+ True
+ True
+
+
+ select
+ Agent traitant
+ center
+ default
+ False
+
+
+
+ folder_manager
+ urban.folder_managers
+
+
+
+
+
+ checkbox
+ État
+ center
+ default
+ False
+ 0
+ 0
+ 0
+ review_state
+ or
+ 0
+ urban.rootfolder_licence_state
+
+ 0
+
+
+ resultsperpage
+ Results per page
+ center
+ default
+ False
+ 0
+ 50
+ 10
+ 20
+
+
+
\ No newline at end of file
diff --git a/src/Products/urban/index.zcml b/src/Products/urban/index.zcml
index e47dc8a51..bfdade719 100644
--- a/src/Products/urban/index.zcml
+++ b/src/Products/urban/index.zcml
@@ -31,6 +31,8 @@
+
+
diff --git a/src/Products/urban/indexes.py b/src/Products/urban/indexes.py
index 204c04f53..f1a2ee745 100644
--- a/src/Products/urban/indexes.py
+++ b/src/Products/urban/indexes.py
@@ -412,3 +412,13 @@ def streetcode_indexer(obj):
@indexer(interfaces.IGenericLicence)
def additional_reference(object):
return object.getAdditionalReference()
+
+
+@indexer(interfaces.IGenericLicence)
+def reference_ft(object):
+ return object.getReferenceFT()
+
+
+@indexer(interfaces.IGenericLicence)
+def reference_dgatlp(object):
+ return object.getReferenceDgatlp()
diff --git a/src/Products/urban/migration/update_270.py b/src/Products/urban/migration/update_270.py
index 316a8e59d..a8aaec03d 100644
--- a/src/Products/urban/migration/update_270.py
+++ b/src/Products/urban/migration/update_270.py
@@ -3,6 +3,7 @@
from Acquisition import aq_parent
from OFS.interfaces import IOrderedContainer
from Products.urban import UrbanMessage as _
+from Products.urban import URBAN_TYPES
from Products.CMFCore.utils import getToolByName
from Products.urban.interfaces import IGenericLicence
from Products.urban.migration.utils import refresh_workflow_permissions
@@ -34,6 +35,7 @@
from plone.restapi.interfaces import ISerializeToJson
from zope.component import getMultiAdapter
from zope.component import getUtility
+from eea.facetednavigation.interfaces import ICriteria
import logging
@@ -45,15 +47,17 @@ def rename_patrimony_certificate(context):
portal = api.portal.get()
patrimony_folder = portal.urban.patrimonycertificates
- patrimony_folder.setTitle(u"Patrimoines")
+ patrimony_folder.setTitle("Patrimoines")
patrimony_folder.reindexObject(["Title"])
- patrimony_collection = portal.urban.patrimonycertificates.collection_patrimonycertificate
- patrimony_collection.setTitle(u"Patrimoines")
+ patrimony_collection = (
+ portal.urban.patrimonycertificates.collection_patrimonycertificate
+ )
+ patrimony_collection.setTitle("Patrimoines")
patrimony_collection.reindexObject(["Title"])
patrimony_config_folder = portal.portal_urban.patrimonycertificate
- patrimony_config_folder.setTitle(u"Paramètres des patrimoines")
+ patrimony_config_folder.setTitle("Paramètres des patrimoines")
patrimony_config_folder.reindexObject(["Title"])
logger.info("upgrade step done!")
@@ -65,7 +69,9 @@ def rename_content_rule(context):
logger.info("starting upgrade steps")
setup_tool = api.portal.get_tool("portal_setup")
- setup_tool.runImportStepFromProfile("profile-Products.urban:default", "contentrules")
+ setup_tool.runImportStepFromProfile(
+ "profile-Products.urban:default", "contentrules"
+ )
logger.info("upgrade step done!")
@@ -78,7 +84,7 @@ def fix_supended_state_licence(context):
refresh_workflow_permissions(
"codt_buildlicence_workflow",
folder_path=urban_path,
- for_states=["suspension", "frozen_suspension"]
+ for_states=["suspension", "frozen_suspension"],
)
logger.info("upgrade done!")
@@ -116,21 +122,20 @@ def _replace_object(obj, new_type, condition=None, logger=None):
if isinstance(round_to_day, dict):
round_to_day = round_to_day.get("token", None)
-
new_obj = api.content.create(
container=container,
type=new_type,
id=old_obj_data["id"],
title=old_obj_data["title"],
start_date=start_date,
- enabled=old_obj_data.get("enabled",None),
+ enabled=old_obj_data.get("enabled", None),
default_assigned_group=default_assigned_group,
default_assigned_user=default_assigned_user,
- warning_delay=old_obj_data.get("warning_delay",None),
- additional_delay=old_obj_data.get("additional_delay",None),
- additional_delay_type=old_obj_data.get("additional_delay_type",None),
+ warning_delay=old_obj_data.get("warning_delay", None),
+ additional_delay=old_obj_data.get("additional_delay", None),
+ additional_delay_type=old_obj_data.get("additional_delay_type", None),
round_to_day=round_to_day,
- activate_recurrency=old_obj_data.get("activate_recurrency",None),
+ activate_recurrency=old_obj_data.get("activate_recurrency", None),
)
log_info(logger, "{} created".format("/".join(obj.getPhysicalPath())))
@@ -169,12 +174,12 @@ def _replace_object(obj, new_type, condition=None, logger=None):
key,
set(
[
- value(
- condition=item.get("condition", None),
- operator=item.get("operator", None),
- display_status=item.get("display_status", None),
- )
- for item in old_obj_data[key]
+ value(
+ condition=item.get("condition", None),
+ operator=item.get("operator", None),
+ display_status=item.get("display_status", None),
+ )
+ for item in old_obj_data[key]
]
),
)
@@ -200,9 +205,11 @@ def _replace_object(obj, new_type, condition=None, logger=None):
dashboard_collection.showNumberOfItems = True
query = [
- {"i": filter["i"], "o": filter["o"], "v": old_obj_data["UID"]}
- if filter["i"] == "CompoundCriterion"
- else filter
+ (
+ {"i": filter["i"], "o": filter["o"], "v": old_obj_data["UID"]}
+ if filter["i"] == "CompoundCriterion"
+ else filter
+ )
for filter in dashboard_collection.query
]
@@ -238,7 +245,9 @@ def fix_config_wrong_class(context):
def add_new_voc_terms_for_form_composition(context):
- logger = logging.getLogger("urban: Add new vocabularies to portal_urban/form_composition")
+ logger = logging.getLogger(
+ "urban: Add new vocabularies to portal_urban/form_composition"
+ )
logger.info("starting upgrade steps")
portal_urban = api.portal.get()["portal_urban"]
@@ -249,35 +258,25 @@ def add_new_voc_terms_for_form_composition(context):
# for the existing vocabulary terms
# that will be initiated in each new instance
form_composition_new_vocabulary_terms_to_add = [
- {
- "id": "10",
- "title": u"1/1 Formulaire général permis environnement et unique"
- },
- {
- "id": "11",
- "title": u"1/2 Élevage et détention d'animaux"
- },
+ {"id": "10", "title": "1/1 Formulaire général permis environnement et unique"},
+ {"id": "11", "title": "1/2 Élevage et détention d'animaux"},
{
"id": "12",
- "title": u"Annexe V/1 - Implantation d'un commerce",
+ "title": "Annexe V/1 - Implantation d'un commerce",
},
{
"id": "13",
- "title": u"Annexe IX - Permis d'urbanisme dispensé d'un architecte ou autre que les demandes visées aux annexes 5 à 8",
+ "title": "Annexe IX - Permis d'urbanisme dispensé d'un architecte ou autre que les demandes visées aux annexes 5 à 8",
},
{
"id": "14",
- "title": u"Annexe X - Demande de permis d'urbanisation ou de modification de permis d'urbanisation"
+ "title": "Annexe X - Demande de permis d'urbanisation ou de modification de permis d'urbanisation",
},
{
"id": "15",
- "title": u"Annexe XI - Demande de permis d'urbanisation ou de modification de permis d'urbanisation avec contenu simplifié"
- },
- {
- "id": "16",
- "title": u"Annexe XV - Demande de certificat d'urbanisme n°2"
+ "title": "Annexe XI - Demande de permis d'urbanisation ou de modification de permis d'urbanisation avec contenu simplifié",
},
-
+ {"id": "16", "title": "Annexe XV - Demande de certificat d'urbanisme n°2"},
]
createFolderDefaultValues(
@@ -304,7 +303,9 @@ def remove_permission_to_create_integrated_licences(context):
remaining_roles = tuple(set(roles).difference(["Contributor"]))
codt_integratedlicences_folder.manage_delLocalRoles([principal_id])
if remaining_roles:
- codt_integratedlicences_folder.manage_addLocalRoles(principal_id, remaining_roles)
+ codt_integratedlicences_folder.manage_addLocalRoles(
+ principal_id, remaining_roles
+ )
codt_integratedlicences_folder.reindexObjectSecurity()
logger.info("upgrade step done!")
@@ -374,7 +375,7 @@ def add_new_registry_profil(context):
logger.info("starting migration steps")
registry = getUtility(IRegistry)
- attributes = {"title": _(u"Planned address"), "description": _(u"address planned")}
+ attributes = {"title": _("Planned address"), "description": _("address planned")}
key = "Products.urban.interfaces.IAsyncInquiryRadius.inquiries_address_to_do"
registry_field = Dict(**attributes)
registry_record = Record(registry_field)
@@ -404,7 +405,9 @@ def hide_patrimony_tab_in_licence_config(context):
for licence_config in portal_urban.objectValues("LicenceConfig"):
if licence_config.id in included:
# add hidden tab config (unless there is one already)
- if not [tab for tab in licence_config.tabsConfig if tab["value"] == "patrimony"]:
+ if not [
+ tab for tab in licence_config.tabsConfig if tab["value"] == "patrimony"
+ ]:
updated_config = licence_config.tabsConfig + (
{"display": "", "display_name": "Patrimoine", "value": "patrimony"},
)
@@ -432,9 +435,17 @@ def hide_tab_in_licence_config(context):
for licence_config in portal_urban.objectValues("LicenceConfig"):
if licence_config.id not in excluded:
# add hidden tab config (unless there is one already)
- if not [tab for tab in licence_config.tabsConfig if tab["value"] == "environment"]:
+ if not [
+ tab
+ for tab in licence_config.tabsConfig
+ if tab["value"] == "environment"
+ ]:
updated_config = licence_config.tabsConfig + (
- {"display": "", "display_name": "Analyse Environnement", "value": "environment"},
+ {
+ "display": "",
+ "display_name": "Analyse Environnement",
+ "value": "environment",
+ },
)
licence_config.setTabsConfig(updated_config)
@@ -454,10 +465,97 @@ def hide_habitation_tab_in_licence_config(context):
for licence_config in portal_urban.objectValues("LicenceConfig"):
if licence_config.id in included:
# add hidden tab config (unless there is one already)
- if not [tab for tab in licence_config.tabsConfig if tab["value"] == "habitation"]:
+ if not [
+ tab for tab in licence_config.tabsConfig if tab["value"] == "habitation"
+ ]:
updated_config = licence_config.tabsConfig + (
{"display": "", "display_name": "Logement", "value": "habitation"},
)
licence_config.setTabsConfig(updated_config)
logger.info("upgrade step done!")
+
+
+class IndexExtras:
+ """Helper class for configuring ZCTextIndex parameters."""
+ def __init__(self):
+ self.index_type = "Okapi BM25 Rank"
+ self.lexicon_id = "plone_lexicon"
+
+def add_indexes_for_reference_fields(context):
+ logger = logging.getLogger("urban: Add index all reference fields")
+ logger.info("starting upgrade steps")
+
+ catalog = api.portal.get_tool("portal_catalog")
+ indexes = ["getReferenceFT", "getReferenceDgatlp"]
+
+ item_extras = IndexExtras()
+
+ for index_name in indexes:
+ if index_name not in catalog.indexes():
+ catalog.addIndex(index_name, "ZCTextIndex", item_extras)
+ logger.info("Added index")
+ else:
+ logger.info("Index already exists")
+
+ if index_name not in catalog.schema():
+ catalog.addColumn(index_name)
+ logger.info("Added metadata column")
+ else:
+ logger.info("Column already exists")
+
+ catalog.reindexIndex(index_name, context.REQUEST)
+ logger.info("Reindexed index")
+
+ logger.info("Upgrade step complete.")
+
+
+def add_reference_filters(context):
+ logger = logging.getLogger("urban: Add reference filters")
+ logger.info("starting : Add reference filters for all procedures")
+
+ setup_tool = api.portal.get_tool("portal_setup")
+ setup_tool.runImportStepFromProfile("profile-Products.urban:urbantypes", "catalog")
+
+ portal = api.portal.get()
+ urban_folder = portal.urban
+ folders = [
+ getattr(urban_folder, urban_type.lower() + "s", None)
+ for urban_type in URBAN_TYPES
+ ]
+ folders.append(urban_folder)
+ criteria_data = [
+ {
+ "_cid_": "c90",
+ "title": "Référence FD (TLPE)",
+ "index": "getReferenceDgatlp",
+ },
+ {
+ "_cid_": "c80",
+ "title": "Référence FT (ARNE)",
+ "index": "getReferenceFT",
+ },
+ ]
+ for folder in filter(None, folders):
+ criteria_adapter = ICriteria(folder)
+ if not criteria_adapter:
+ continue
+
+ existing_ids = {c.getId() for c in criteria_adapter.criteria}
+
+ for criterion_data in criteria_data:
+ cid = criterion_data["_cid_"]
+ if cid not in existing_ids:
+ criteria_adapter.add(
+ wid="text",
+ position="top",
+ section="advanced",
+ hidden=False,
+ **criterion_data
+ )
+ logger.info("Added criterion")
+ else:
+ logger.info("Criterion already exists")
+
+ logger.info("Upgrade done!")
+
\ No newline at end of file
diff --git a/src/Products/urban/migration/upgrades.zcml b/src/Products/urban/migration/upgrades.zcml
index a79bdbbca..011133b8c 100644
--- a/src/Products/urban/migration/upgrades.zcml
+++ b/src/Products/urban/migration/upgrades.zcml
@@ -773,5 +773,21 @@
handler=".update_270.add_new_registry_profil"
profile="Products.urban:default"
/>
-
+
+
+
diff --git a/src/Products/urban/profiles/default/metadata.xml b/src/Products/urban/profiles/default/metadata.xml
index 151f78f29..86b1cbeb3 100644
--- a/src/Products/urban/profiles/default/metadata.xml
+++ b/src/Products/urban/profiles/default/metadata.xml
@@ -1,7 +1,7 @@
- 1164
+ 1166
profile-Products.urban:preinstall
-
+
\ No newline at end of file
diff --git a/src/Products/urban/profiles/urban_types/catalog.xml b/src/Products/urban/profiles/urban_types/catalog.xml
index 9198409a3..375a5eb47 100644
--- a/src/Products/urban/profiles/urban_types/catalog.xml
+++ b/src/Products/urban/profiles/urban_types/catalog.xml
@@ -1,126 +1,142 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file