diff --git a/news/URB-3651.feature b/news/URB-3651.feature
new file mode 100644
index 000000000..bd5de8a3f
--- /dev/null
+++ b/news/URB-3651.feature
@@ -0,0 +1,2 @@
+Add index and widget to filter by last received NOTICe notification
+[daggelpop]
\ 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 a0c2a7120..cdca67c10 100644
--- a/src/Products/urban/dashboard/config/all.xml
+++ b/src/Products/urban/dashboard/config/all.xml
@@ -161,5 +161,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/article127s.xml b/src/Products/urban/dashboard/config/article127s.xml
index 6f4ca48ca..a6aba46b8 100644
--- a/src/Products/urban/dashboard/config/article127s.xml
+++ b/src/Products/urban/dashboard/config/article127s.xml
@@ -173,5 +173,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/buildlicences.xml b/src/Products/urban/dashboard/config/buildlicences.xml
index fdfc51900..cd74fed6f 100644
--- a/src/Products/urban/dashboard/config/buildlicences.xml
+++ b/src/Products/urban/dashboard/config/buildlicences.xml
@@ -185,5 +185,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/codt_article127s.xml b/src/Products/urban/dashboard/config/codt_article127s.xml
index 20a46630b..53522ce66 100644
--- a/src/Products/urban/dashboard/config/codt_article127s.xml
+++ b/src/Products/urban/dashboard/config/codt_article127s.xml
@@ -185,5 +185,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/codt_buildlicences.xml b/src/Products/urban/dashboard/config/codt_buildlicences.xml
index d54c95eaa..f1bc0e39f 100644
--- a/src/Products/urban/dashboard/config/codt_buildlicences.xml
+++ b/src/Products/urban/dashboard/config/codt_buildlicences.xml
@@ -195,5 +195,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/codt_commerciallicences.xml b/src/Products/urban/dashboard/config/codt_commerciallicences.xml
index efdb996a3..73651d8d0 100644
--- a/src/Products/urban/dashboard/config/codt_commerciallicences.xml
+++ b/src/Products/urban/dashboard/config/codt_commerciallicences.xml
@@ -184,5 +184,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/codt_integratedlicences.xml b/src/Products/urban/dashboard/config/codt_integratedlicences.xml
index efdb996a3..73651d8d0 100644
--- a/src/Products/urban/dashboard/config/codt_integratedlicences.xml
+++ b/src/Products/urban/dashboard/config/codt_integratedlicences.xml
@@ -184,5 +184,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/codt_notaryletters.xml b/src/Products/urban/dashboard/config/codt_notaryletters.xml
index 7891fc934..db4d51b40 100644
--- a/src/Products/urban/dashboard/config/codt_notaryletters.xml
+++ b/src/Products/urban/dashboard/config/codt_notaryletters.xml
@@ -173,5 +173,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/codt_parceloutlicences.xml b/src/Products/urban/dashboard/config/codt_parceloutlicences.xml
index f6e7b4982..85b96d539 100644
--- a/src/Products/urban/dashboard/config/codt_parceloutlicences.xml
+++ b/src/Products/urban/dashboard/config/codt_parceloutlicences.xml
@@ -184,5 +184,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/codt_uniqueborderinglicences.xml b/src/Products/urban/dashboard/config/codt_uniqueborderinglicences.xml
index c0c43fe15..3f11bd871 100644
--- a/src/Products/urban/dashboard/config/codt_uniqueborderinglicences.xml
+++ b/src/Products/urban/dashboard/config/codt_uniqueborderinglicences.xml
@@ -184,5 +184,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/codt_uniquelicences.xml b/src/Products/urban/dashboard/config/codt_uniquelicences.xml
index efdb996a3..73651d8d0 100644
--- a/src/Products/urban/dashboard/config/codt_uniquelicences.xml
+++ b/src/Products/urban/dashboard/config/codt_uniquelicences.xml
@@ -184,5 +184,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/codt_urbancertificateones.xml b/src/Products/urban/dashboard/config/codt_urbancertificateones.xml
index 305525859..f5a01b8a7 100644
--- a/src/Products/urban/dashboard/config/codt_urbancertificateones.xml
+++ b/src/Products/urban/dashboard/config/codt_urbancertificateones.xml
@@ -173,5 +173,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/codt_urbancertificatetwos.xml b/src/Products/urban/dashboard/config/codt_urbancertificatetwos.xml
index efdb996a3..73651d8d0 100644
--- a/src/Products/urban/dashboard/config/codt_urbancertificatetwos.xml
+++ b/src/Products/urban/dashboard/config/codt_urbancertificatetwos.xml
@@ -184,5 +184,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/declarations.xml b/src/Products/urban/dashboard/config/declarations.xml
index d48f65690..83a346354 100644
--- a/src/Products/urban/dashboard/config/declarations.xml
+++ b/src/Products/urban/dashboard/config/declarations.xml
@@ -91,5 +91,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/divisions.xml b/src/Products/urban/dashboard/config/divisions.xml
index 765aba4a1..ff520bba8 100644
--- a/src/Products/urban/dashboard/config/divisions.xml
+++ b/src/Products/urban/dashboard/config/divisions.xml
@@ -173,5 +173,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/envclassborderings.xml b/src/Products/urban/dashboard/config/envclassborderings.xml
index efdb996a3..73651d8d0 100644
--- a/src/Products/urban/dashboard/config/envclassborderings.xml
+++ b/src/Products/urban/dashboard/config/envclassborderings.xml
@@ -184,5 +184,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/envclassones.xml b/src/Products/urban/dashboard/config/envclassones.xml
index efdb996a3..73651d8d0 100644
--- a/src/Products/urban/dashboard/config/envclassones.xml
+++ b/src/Products/urban/dashboard/config/envclassones.xml
@@ -184,5 +184,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/envclassthrees.xml b/src/Products/urban/dashboard/config/envclassthrees.xml
index 430100116..cb5cbabbf 100644
--- a/src/Products/urban/dashboard/config/envclassthrees.xml
+++ b/src/Products/urban/dashboard/config/envclassthrees.xml
@@ -162,5 +162,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/envclasstwos.xml b/src/Products/urban/dashboard/config/envclasstwos.xml
index efdb996a3..73651d8d0 100644
--- a/src/Products/urban/dashboard/config/envclasstwos.xml
+++ b/src/Products/urban/dashboard/config/envclasstwos.xml
@@ -184,5 +184,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/explosivespossessions.xml b/src/Products/urban/dashboard/config/explosivespossessions.xml
index 1edb177f8..66d43a7e1 100644
--- a/src/Products/urban/dashboard/config/explosivespossessions.xml
+++ b/src/Products/urban/dashboard/config/explosivespossessions.xml
@@ -172,5 +172,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/housings.xml b/src/Products/urban/dashboard/config/housings.xml
index 15437e1f2..b0189fb8e 100644
--- a/src/Products/urban/dashboard/config/housings.xml
+++ b/src/Products/urban/dashboard/config/housings.xml
@@ -156,5 +156,15 @@
10
20
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
\ No newline at end of file
diff --git a/src/Products/urban/dashboard/config/import_notice.xml b/src/Products/urban/dashboard/config/import_notice.xml
index a0c2a7120..cdca67c10 100644
--- a/src/Products/urban/dashboard/config/import_notice.xml
+++ b/src/Products/urban/dashboard/config/import_notice.xml
@@ -161,5 +161,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/inspections.xml b/src/Products/urban/dashboard/config/inspections.xml
index 1edb177f8..66d43a7e1 100644
--- a/src/Products/urban/dashboard/config/inspections.xml
+++ b/src/Products/urban/dashboard/config/inspections.xml
@@ -172,5 +172,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/integratedlicences.xml b/src/Products/urban/dashboard/config/integratedlicences.xml
index c49fbe939..e18a95198 100644
--- a/src/Products/urban/dashboard/config/integratedlicences.xml
+++ b/src/Products/urban/dashboard/config/integratedlicences.xml
@@ -173,5 +173,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/miscdemands.xml b/src/Products/urban/dashboard/config/miscdemands.xml
index a59326092..daf0bf859 100644
--- a/src/Products/urban/dashboard/config/miscdemands.xml
+++ b/src/Products/urban/dashboard/config/miscdemands.xml
@@ -174,5 +174,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/notaryletters.xml b/src/Products/urban/dashboard/config/notaryletters.xml
index 258d9af36..e7deb5d00 100644
--- a/src/Products/urban/dashboard/config/notaryletters.xml
+++ b/src/Products/urban/dashboard/config/notaryletters.xml
@@ -162,5 +162,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/parceloutlicences.xml b/src/Products/urban/dashboard/config/parceloutlicences.xml
index 20420fd86..befe45052 100644
--- a/src/Products/urban/dashboard/config/parceloutlicences.xml
+++ b/src/Products/urban/dashboard/config/parceloutlicences.xml
@@ -92,5 +92,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/patrimonycertificates.xml b/src/Products/urban/dashboard/config/patrimonycertificates.xml
index a59326092..daf0bf859 100644
--- a/src/Products/urban/dashboard/config/patrimonycertificates.xml
+++ b/src/Products/urban/dashboard/config/patrimonycertificates.xml
@@ -174,5 +174,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/preliminarynotices.xml b/src/Products/urban/dashboard/config/preliminarynotices.xml
index a59326092..daf0bf859 100644
--- a/src/Products/urban/dashboard/config/preliminarynotices.xml
+++ b/src/Products/urban/dashboard/config/preliminarynotices.xml
@@ -174,5 +174,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/projectmeetings.xml b/src/Products/urban/dashboard/config/projectmeetings.xml
index a59326092..daf0bf859 100644
--- a/src/Products/urban/dashboard/config/projectmeetings.xml
+++ b/src/Products/urban/dashboard/config/projectmeetings.xml
@@ -174,5 +174,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/roaddecrees.xml b/src/Products/urban/dashboard/config/roaddecrees.xml
index 4a660bded..89e59d1b1 100644
--- a/src/Products/urban/dashboard/config/roaddecrees.xml
+++ b/src/Products/urban/dashboard/config/roaddecrees.xml
@@ -161,5 +161,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/tickets.xml b/src/Products/urban/dashboard/config/tickets.xml
index 1edb177f8..66d43a7e1 100644
--- a/src/Products/urban/dashboard/config/tickets.xml
+++ b/src/Products/urban/dashboard/config/tickets.xml
@@ -172,5 +172,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/uniquelicences.xml b/src/Products/urban/dashboard/config/uniquelicences.xml
index c49fbe939..e18a95198 100644
--- a/src/Products/urban/dashboard/config/uniquelicences.xml
+++ b/src/Products/urban/dashboard/config/uniquelicences.xml
@@ -173,5 +173,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/urbancertificateones.xml b/src/Products/urban/dashboard/config/urbancertificateones.xml
index 258d9af36..e7deb5d00 100644
--- a/src/Products/urban/dashboard/config/urbancertificateones.xml
+++ b/src/Products/urban/dashboard/config/urbancertificateones.xml
@@ -162,5 +162,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/dashboard/config/urbancertificatetwos.xml b/src/Products/urban/dashboard/config/urbancertificatetwos.xml
index c49fbe939..e18a95198 100644
--- a/src/Products/urban/dashboard/config/urbancertificatetwos.xml
+++ b/src/Products/urban/dashboard/config/urbancertificatetwos.xml
@@ -173,5 +173,15 @@
False
False
+
+ daterange
+ Dernier événement reçu
+ top
+ advanced
+ False
+ last_received_notice_notification
+
+ c-10:c+10
+
diff --git a/src/Products/urban/index.zcml b/src/Products/urban/index.zcml
index e47dc8a51..aa40e6f36 100644
--- a/src/Products/urban/index.zcml
+++ b/src/Products/urban/index.zcml
@@ -31,6 +31,7 @@
+
diff --git a/src/Products/urban/indexes.py b/src/Products/urban/indexes.py
index 9a3172b2b..0e6e2dafd 100644
--- a/src/Products/urban/indexes.py
+++ b/src/Products/urban/indexes.py
@@ -26,6 +26,7 @@
from plone import api
from plone.indexer import indexer
from requests.exceptions import RequestException
+from zope.annotation.interfaces import IAnnotations
from zope.component import queryAdapter
from zope.interface import Interface
@@ -426,3 +427,23 @@ def streetcode_indexer(obj):
@indexer(interfaces.IGenericLicence)
def additional_reference(object):
return object.getAdditionalReference()
+
+
+@indexer(interfaces.IGenericLicence)
+def last_received_notice_notification(object):
+ """
+ Get the creation date of the last received NOTICe event
+ """
+
+ all_licence_events = sorted(
+ object.getAllEvents(), key=lambda e: e.created(), reverse=True
+ )
+ for event in all_licence_events:
+ annotations = IAnnotations(event)
+ key = "notice_notification"
+ notice = annotations.get(key, {})
+ incoming = notice.get("incoming", {})
+ if incoming.get("notice_id"):
+ return event.created()
+
+ return None
diff --git a/src/Products/urban/migration/update_290.py b/src/Products/urban/migration/update_290.py
index 1bfa5055e..570261dac 100644
--- a/src/Products/urban/migration/update_290.py
+++ b/src/Products/urban/migration/update_290.py
@@ -14,6 +14,7 @@
from Products.urban.utils import moveElementAfter
from Products.urban.setuphandlers import set_licence_folder_security
from dm.historical import getHistory
+from eea.facetednavigation.criteria.interfaces import ICriteria
from imio.helpers.catalog import reindexIndexes
from plone import api
from plone.app.textfield import RichTextValue
@@ -702,6 +703,41 @@ def normalize_externaldecisions_vocabulary(context):
logger.info("Upgrade done!")
+def add_last_received_notice_notification(context):
+ logger = logging.getLogger("urban: Add last received notice notification")
+
+ # add catalog index
+ setup_tool = api.portal.get_tool("portal_setup")
+ setup_tool.runImportStepFromProfile("profile-Products.urban:urbantypes", "catalog")
+ reindexIndexes(None, ["last_received_notice_notification"])
+
+ # add dashboard widget
+ urban_base_folder = api.portal.get().urban
+ urban_dashboard_folders = [urban_base_folder] # needed for dashboard 'All'
+ if "import-notice" in urban_base_folder.objectIds():
+ urban_dashboard_folders.append(getattr(urban_base_folder, "import-notice"))
+ for urban_type in URBAN_TYPES:
+ licence_folder = getattr(urban_base_folder, "{}s".format(urban_type.lower()), None)
+ if licence_folder is not None:
+ urban_dashboard_folders.append(licence_folder)
+
+ for licence_folder in urban_dashboard_folders:
+ criteria = ICriteria(licence_folder)
+ if criteria is not None and not criteria.get("c96"):
+ criteria.add(
+ _cid_=u"c96",
+ wid="daterange",
+ title=u"Dernier événement reçu",
+ position="top",
+ section="advanced",
+ hidden=False,
+ index=u"last_received_notice_notification",
+ calYearRange=u"c-10:c+10",
+ )
+
+ logger.info("upgrade step done!")
+
+
def setup_referenceFT_PM(context):
logger = logging.getLogger("urban: Set up `referenceFT_PM` index and attribute")
diff --git a/src/Products/urban/migration/upgrades_290.zcml b/src/Products/urban/migration/upgrades_290.zcml
index 73eacc52a..517f98f77 100644
--- a/src/Products/urban/migration/upgrades_290.zcml
+++ b/src/Products/urban/migration/upgrades_290.zcml
@@ -156,4 +156,12 @@
handler=".update_290.setup_referenceFT_PM"
profile="Products.urban:default" />
+
+
diff --git a/src/Products/urban/profiles/default/metadata.xml b/src/Products/urban/profiles/default/metadata.xml
index 8ecb9f459..dc929175f 100644
--- a/src/Products/urban/profiles/default/metadata.xml
+++ b/src/Products/urban/profiles/default/metadata.xml
@@ -1,6 +1,6 @@
- 2919
+ 2920
profile-Products.urban:preinstall
diff --git a/src/Products/urban/profiles/urban_types/catalog.xml b/src/Products/urban/profiles/urban_types/catalog.xml
index 29fc10116..396600474 100644
--- a/src/Products/urban/profiles/urban_types/catalog.xml
+++ b/src/Products/urban/profiles/urban_types/catalog.xml
@@ -143,5 +143,10 @@
+
+
+
+
+