diff --git a/news/URB-3595.feature b/news/URB-3595.feature
new file mode 100644
index 000000000..8bb2343de
--- /dev/null
+++ b/news/URB-3595.feature
@@ -0,0 +1,2 @@
+Add dematerialized encoding warning on NOTICE folder
+[WBoudabous]
\ No newline at end of file
diff --git a/src/Products/urban/browser/cron/notice.py b/src/Products/urban/browser/cron/notice.py
index d061df6d3..806386b15 100644
--- a/src/Products/urban/browser/cron/notice.py
+++ b/src/Products/urban/browser/cron/notice.py
@@ -7,6 +7,7 @@
from Products.urban.contentrules.notice import NoticeImportFailedEvent
from Products.urban.contentrules.notice import NoticeImportSucceededEvent
from Products.urban.interfaces import IBaseBuildLicence
+from Products.urban.interfaces import ILicenceCreatedViaNoticeWS
from Products.urban.notice.exceptions import ErrorProcessingNotificationException
from Products.urban.notice.exceptions import FailedGettingRecentNotificationsException
from Products.urban.notice.exceptions import NoImplementationFoundException
@@ -21,6 +22,7 @@
from zope.annotation.interfaces import IAnnotations
from zope.event import notify
from zope.i18n import translate
+from zope.interface import alsoProvides
from zope.lifecycleevent import ObjectModifiedEvent
import logging
@@ -330,6 +332,7 @@ def create_licence(self):
self.licence = api.content.create(
container=self.notification.container, **self.notification.serialize()
)
+ alsoProvides(self.licence, ILicenceCreatedViaNoticeWS)
if IBaseBuildLicence.providedBy(self.licence):
self.licence.setUsage("not_applicable")
self.licence.setFoldermanagers(
diff --git a/src/Products/urban/browser/warnings/conditions.py b/src/Products/urban/browser/warnings/conditions.py
index 775393d8d..5a16471de 100644
--- a/src/Products/urban/browser/warnings/conditions.py
+++ b/src/Products/urban/browser/warnings/conditions.py
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
+from Products.urban.interfaces import ILicenceCreatedViaNoticeWS
from Products.urban.interfaces import IUrbanWarningCondition
from plone import api
from zope.interface import implements
-
class WarningCondition(object):
"""
Base class for any object adapting a licence into a warning
@@ -43,3 +43,12 @@ def evaluate(self):
):
return True
return False
+
+
+class NoticeWarning(WarningCondition):
+ """
+ Check if license is a notice folder.
+ """
+
+ def evaluate(self):
+ return ILicenceCreatedViaNoticeWS.providedBy(self.licence)
\ No newline at end of file
diff --git a/src/Products/urban/browser/warnings/configure.zcml b/src/Products/urban/browser/warnings/configure.zcml
index 1c85a964f..34e49de75 100644
--- a/src/Products/urban/browser/warnings/configure.zcml
+++ b/src/Products/urban/browser/warnings/configure.zcml
@@ -18,4 +18,11 @@
name="urban.warnings.bound_ticket_settlement"
/>
+
+
diff --git a/src/Products/urban/interfaces.py b/src/Products/urban/interfaces.py
index 608be2afa..268bcbcb2 100644
--- a/src/Products/urban/interfaces.py
+++ b/src/Products/urban/interfaces.py
@@ -195,6 +195,10 @@ class IUrbanEventNotice(Interface):
"""Marker interface for .UrbanEventNotice.UrbanEventNotice"""
+class ILicenceCreatedViaNoticeWS(Interface):
+ """Marker interface for a licence created through the Notice webservice"""
+
+
class IUrbanEventOpinionRequest(Interface):
"""Marker interface for .UrbanEventOpinionRequest.UrbanEventOpinionRequest"""
diff --git a/src/Products/urban/locales/fr/LC_MESSAGES/urban.po b/src/Products/urban/locales/fr/LC_MESSAGES/urban.po
index b802e0f84..dbfb24899 100644
--- a/src/Products/urban/locales/fr/LC_MESSAGES/urban.po
+++ b/src/Products/urban/locales/fr/LC_MESSAGES/urban.po
@@ -5980,3 +5980,9 @@ msgstr "Plans Modificatifs - Notification à la commune que le RS vaut décision
msgid "PM_REFUS_TACITE_COMMUNE"
msgstr "Plans modificatifs - Notification à la commune du refus tacite"
+
+msgstr "Nature de l'immeuble"
+msgstr "Nature de l'immeuble"
+
+msgid "urban.warnings.notice"
+msgstr "Ce dossier a été encodé de manière dématérialisée"
diff --git a/src/Products/urban/migration/update_290.py b/src/Products/urban/migration/update_290.py
index 1bfa5055e..ea93b23a0 100644
--- a/src/Products/urban/migration/update_290.py
+++ b/src/Products/urban/migration/update_290.py
@@ -9,6 +9,9 @@
from Products.urban.contentrules.notice import INoticeImportSucceededEvent
from Products.urban.contentrules.notice import INoticeResponseFailedEvent
from Products.urban.contentrules.utils import ContentRulesUtils
+from Products.urban.interfaces import IGenericLicence
+from Products.urban.interfaces import ILicenceCreatedViaNoticeWS
+from Products.urban.interfaces import IUrbanEventNotice
from Products.urban.migration.utils import cook_javascript_resources
from Products.urban.setuphandlers import add_new_urban_licence_type
from Products.urban.utils import moveElementAfter
@@ -20,8 +23,11 @@
from plone.registry import field
from plone.registry import Record
from plone.registry.interfaces import IRegistry
+from zope.annotation.interfaces import IAnnotations
from zope.component import getUtility
from zope.event import notify
+from zope.i18n import translate
+from zope.interface import alsoProvides
import logging
@@ -721,3 +727,37 @@ def setup_referenceFT_PM(context):
reindexIndexes(None, ["referenceFT_PM"])
logger.info("upgrade step done!")
+def add_notice_warning(context):
+ """
+ Add notice warning on portal_urban warnings field.
+ """
+ logger = logging.getLogger("urban: Add notice warning")
+ logger.info("starting upgrade steps")
+ portal_urban = api.portal.get_tool("portal_urban")
+ existing = list(portal_urban.getWarnings())
+ names = [w["condition"] for w in existing]
+ if "urban.warnings.notice" not in names:
+ existing.append(
+ {
+ "condition": "urban.warnings.notice",
+ "level": "warning",
+ "message": translate(
+ "urban.warnings.notice",
+ domain="urban",
+ target_language="fr",
+ default=u"Ce dossier a été encodé de manière dématérialisée",
+ ).encode("utf-8"),
+ }
+ )
+ portal_urban.setWarnings(tuple(existing))
+
+ catalog = api.portal.get_tool("portal_catalog")
+ licence_brains = catalog(object_provides=IGenericLicence.__identifier__)
+ for licence_brain in licence_brains:
+ licence = licence_brain.getObject()
+ for event in licence.getAllEvents(IUrbanEventNotice):
+ if IAnnotations(event).get("notice_notification", {}):
+ alsoProvides(licence, ILicenceCreatedViaNoticeWS)
+ break
+
+ logger.info("upgrade done!")
diff --git a/src/Products/urban/migration/upgrades_290.zcml b/src/Products/urban/migration/upgrades_290.zcml
index 73eacc52a..14bba3108 100644
--- a/src/Products/urban/migration/upgrades_290.zcml
+++ b/src/Products/urban/migration/upgrades_290.zcml
@@ -156,4 +156,11 @@
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