diff --git a/news/URB-3640.feature b/news/URB-3640.feature new file mode 100644 index 000000000..8c4305f36 --- /dev/null +++ b/news/URB-3640.feature @@ -0,0 +1,2 @@ +Handle PM_EP_COURRIER_COMMUNE notification +[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 caeaf3db1..ab280cec0 100644 --- a/src/Products/urban/browser/cron/notice.py +++ b/src/Products/urban/browser/cron/notice.py @@ -43,13 +43,10 @@ def _initialize(self): self.notice_service = notice.WebserviceNotice() self.retry_failed_notifications = self.request.form.get("retry") == "1" - self.last_import_date = ( - api.portal.get_registry_record( - "Products.urban.browser.notice_settings.INoticeSettings.last_import_date", - default=datetime(2000, 1, 1), - ) - or datetime(2000, 1, 1) - ) + self.last_import_date = api.portal.get_registry_record( + "Products.urban.browser.notice_settings.INoticeSettings.last_import_date", + default=datetime(2000, 1, 1), + ) or datetime(2000, 1, 1) self.latest_successful_date = self.last_import_date self.failed_notifications = ( api.portal.get_registry_record( @@ -65,7 +62,7 @@ def _retry_failed_notifications(self): if not self.retry_failed_notifications or not self.failed_notifications: return - logger.info(u"Retrying %d failed notifications", len(self.failed_notifications)) + logger.info("Retrying %d failed notifications", len(self.failed_notifications)) remaining_failed = [] for failed_notice_id in self.failed_notifications: @@ -75,14 +72,14 @@ def _retry_failed_notifications(self): savepoint = transaction.savepoint() try: self._handle_notification(failed_notice_id) - logger.info(u"Retried notification %s succeeded", failed_notice_id) + logger.info("Retried notification %s succeeded", failed_notice_id) except Exception as exc: savepoint.rollback() custom_exc = ErrorProcessingNotificationException( failed_notice_id, exc, retry=True ) logger.exception( - u"%s", + "%s", custom_exc, ) self._notify_import_error( @@ -123,12 +120,12 @@ def _process_fresh_notifications(self): self._handle_notification(notice_id) if notif_last_status_date > self.latest_successful_date: self.latest_successful_date = notif_last_status_date - logger.info(u"Notification %s succeeded", notice_id) + logger.info("Notification %s succeeded", notice_id) except Exception as exc: savepoint.rollback() custom_exc = ErrorProcessingNotificationException(notice_id, exc) logger.exception( - u"%s", + "%s", custom_exc, ) self._notify_import_error( @@ -146,7 +143,7 @@ def _save_progress(self): self.latest_successful_date, ) logger.info( - u"Updated last_import_date to %s", + "Updated last_import_date to %s", self.latest_successful_date.isoformat(), ) @@ -156,7 +153,7 @@ def _save_progress(self): ) if self.failed_notifications: logger.warning( - u"%d notification(s) recorded as failed", len(self.failed_notifications) + "%d notification(s) recorded as failed", len(self.failed_notifications) ) def _get_notice_notifications(self): @@ -166,7 +163,7 @@ def _get_notice_notifications(self): except Exception as exc: custom_exc = FailedGettingRecentNotificationsException(exc) logger.exception( - u"%s", + "%s", custom_exc, ) self._notify_import_error( @@ -185,7 +182,7 @@ def _notify_import_error(self, notice_id="", error_message=""): notify(NoticeImportFailedEvent(event_wrapper)) except Exception: logger.exception( - u"Failed to emit NoticeImportFailedEvent for notice_id=%s", + "Failed to emit NoticeImportFailedEvent for notice_id=%s", notice_id, ) @@ -268,6 +265,7 @@ def _handle_notification(self, notice_id): "DEMANDE_AVIS_FACULTATIF_PLAN_MODIFIE_1_ERE_INSTANCE", "DEMANDE_ENQUETE_PUBLIQUE_PLAN_MODIFIE_1_ERE_INSTANCE", "DEMANDE_ANNONCE_PROJET_PLAN_MODIFIE_1_ERE_INSTANCE", + "PM_EP_COURRIER_COMMUNE", ): handler = GesperAmendedPlansSPWHandler elif detailed_notification.notice_type in ( @@ -335,12 +333,22 @@ def import_parcels(self): if not parcel.parcel: data = { translate(_("CaPaKey"), context=self.request): parcel.capakey, - translate(_("urban_label_division"), context=self.request): parcel.division, - translate(_("urban_label_section"), context=self.request): parcel.section, - translate(_("urban_label_radical"), context=self.request): parcel.radical, + translate( + _("urban_label_division"), context=self.request + ): parcel.division, + translate( + _("urban_label_section"), context=self.request + ): parcel.section, + translate( + _("urban_label_radical"), context=self.request + ): parcel.radical, translate(_("urban_label_bis"), context=self.request): parcel.bis, - translate(_("urban_label_exposant"), context=self.request): parcel.exposant, - translate(_("urban_label_puissance"), context=self.request): parcel.puissance, + translate( + _("urban_label_exposant"), context=self.request + ): parcel.exposant, + translate( + _("urban_label_puissance"), context=self.request + ): parcel.puissance, } self._add_error(_("Can not find a parcel"), data) continue @@ -349,13 +357,21 @@ def import_parcels(self): def import_addresses(self): for address in self.notification.addresses: data = { - translate(_("urban_label_street"), context=self.request): address.notice_street, - translate(_("urban_label_locality"), context=self.request): address.locality, + translate( + _("urban_label_street"), context=self.request + ): address.notice_street, + translate( + _("urban_label_locality"), context=self.request + ): address.locality, translate( _("municipality"), context=self.request ): address.municipality, - translate(_("urban_label_zipCode"), context=self.request): address.postCode, - translate(_("urban_label_number"), context=self.request): address.number, + translate( + _("urban_label_zipCode"), context=self.request + ): address.postCode, + translate( + _("urban_label_number"), context=self.request + ): address.number, } if not address.address: self._add_error(_("Can not find an address"), data) @@ -446,24 +462,26 @@ def set_reference_dgatlp(self): def _add_error(self, msg, serialized_data): error = _( - u"
${msg} for informations: ${data}
", + "${msg} for informations: ${data}
", mapping={ "msg": msg, - "data": u", ".join( - [u"{0}: {1}".format(k, v) for k, v in serialized_data.items()] + "data": ", ".join( + ["{0}: {1}".format(k, v) for k, v in serialized_data.items()] ), }, ) description_field = self.licence.getField("description") old_description = description_field.getRaw(self.licence) - new_description = old_description + translate(error, context=self.request).encode("utf8") + new_description = old_description + translate( + error, context=self.request + ).encode("utf8") description_field.set(self.licence, new_description) self.licence._p_changed = 1 @property def _notification_transition_comment(self): msg = _( - u"NOTICe notification n° ${noticeId}", + "NOTICe notification n° ${noticeId}", mapping={ "noticeId": self.notification.noticeId, }, @@ -483,7 +501,7 @@ def notify_successful_import(self): notify(NoticeImportSucceededEvent(event_wrapper)) except Exception: logger.exception( - u"Failed to emit NoticeImportSucceededEvent for notice_id=%s", + "Failed to emit NoticeImportSucceededEvent for notice_id=%s", notice_id, ) @@ -612,7 +630,7 @@ def fill_incoming_event(self): self.event.setDecision(urban_decision_term) else: self.event.setDescription( - u"Décision: {}".format(self.notification.decision_code) + "Décision: {}".format(self.notification.decision_code) ) @property @@ -651,15 +669,11 @@ def fill_incoming_event(self): "UFD2_DECISION_FD_OCTROI": "favorable", "UFD2_DECISION_FD_REFUSEE": "defavorable", } - urban_decision_term = mapping_decision_terms.get( - decision_code - ) + urban_decision_term = mapping_decision_terms.get(decision_code) if urban_decision_term: self.event.setDecision(urban_decision_term) else: - self.event.setDescription( - u"Décision: {}".format(decision_code) - ) + self.event.setDescription("Décision: {}".format(decision_code)) @property def desired_licence_state(self): diff --git a/src/Products/urban/browser/urbaneventviews.py b/src/Products/urban/browser/urbaneventviews.py index cc5cdaf7a..514a76d23 100644 --- a/src/Products/urban/browser/urbaneventviews.py +++ b/src/Products/urban/browser/urbaneventviews.py @@ -1458,6 +1458,7 @@ class CanTransferDatesGesperEPView(CanTransferNoticeBaseView): "DEMANDE_ENQUETE_PUBLIQUE_PLAN_MODIFIE_1_ERE_INSTANCE", "DEMANDE_ENQUETE_PUBLIQUE_PLAN_INITIAL_2_EME_INSTANCE", "DEMANDE_ENQUETE_PUBLIQUE_PLAN_MODIFIE_2_EME_INSTANCE", + "PM_EP_COURRIER_COMMUNE", ] avoided_outgoing_notice_types = ["transfer_dates_gesper_ep"] @@ -1469,6 +1470,7 @@ class CanTransferTicketGesperEPView(CanTransferNoticeBaseView): "DEMANDE_ENQUETE_PUBLIQUE_PLAN_MODIFIE_1_ERE_INSTANCE", "DEMANDE_ENQUETE_PUBLIQUE_PLAN_INITIAL_2_EME_INSTANCE", "DEMANDE_ENQUETE_PUBLIQUE_PLAN_MODIFIE_2_EME_INSTANCE", + "PM_EP_COURRIER_COMMUNE", ] avoided_outgoing_notice_types = [ "transfer_ticket_gesper_ep", @@ -1484,6 +1486,7 @@ class CanTransferOpinionGesperEPView(CanTransferNoticeBaseView): "DEMANDE_ENQUETE_PUBLIQUE_PLAN_MODIFIE_1_ERE_INSTANCE", "DEMANDE_ENQUETE_PUBLIQUE_PLAN_INITIAL_2_EME_INSTANCE", "DEMANDE_ENQUETE_PUBLIQUE_PLAN_MODIFIE_2_EME_INSTANCE", + "PM_EP_COURRIER_COMMUNE", ] avoided_outgoing_notice_types = [ "transfer_opinion_gesper_ep", diff --git a/src/Products/urban/locales/fr/LC_MESSAGES/urban.po b/src/Products/urban/locales/fr/LC_MESSAGES/urban.po index d7b41e9e2..a257c4736 100644 --- a/src/Products/urban/locales/fr/LC_MESSAGES/urban.po +++ b/src/Products/urban/locales/fr/LC_MESSAGES/urban.po @@ -369,6 +369,9 @@ msgstr "Demande d'organisation d'une enquête publique (interrogée précédemme msgid "DEMANDE_EP_EXTRA" msgstr "Demande d'organisation d'une enquête publique (hors territoire)" +msgid "PM_EP_COURRIER_COMMUNE" +msgstr "Demande d'organisation d'une enquête publique - Plans Modificatifs" + #: ../browser/offdays_settings.py:47 msgid "Date" msgstr "Date" diff --git a/src/Products/urban/locales/urban-manual.pot b/src/Products/urban/locales/urban-manual.pot index 93eaef19d..4323c9103 100644 --- a/src/Products/urban/locales/urban-manual.pot +++ b/src/Products/urban/locales/urban-manual.pot @@ -1697,4 +1697,5 @@ msgid "DECISION_GESPER_2_EME_INSTANCE" msgstr "" msgid "PM_ENVOI_RS_HD_SFD_COMMUNE" +msgid "PM_EP_COURRIER_COMMUNE" msgstr "" \ No newline at end of file diff --git a/src/Products/urban/locales/urban.pot b/src/Products/urban/locales/urban.pot index 9c36e48b6..79d628920 100644 --- a/src/Products/urban/locales/urban.pot +++ b/src/Products/urban/locales/urban.pot @@ -5931,3 +5931,5 @@ msgstr "" msgid "PM_ENVOI_RS_HD_SFD_COMMUNE" msgstr "" +msgid "PM_EP_COURRIER_COMMUNE" +msgstr ""