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 d061df6d3..503fa4e53 100644 --- a/src/Products/urban/browser/cron/notice.py +++ b/src/Products/urban/browser/cron/notice.py @@ -45,13 +45,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( @@ -67,7 +64,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: @@ -77,7 +74,7 @@ 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( @@ -125,7 +122,7 @@ 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) @@ -148,7 +145,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(), ) @@ -158,7 +155,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): @@ -187,7 +184,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, ) @@ -277,6 +274,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 ( @@ -353,12 +351,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 @@ -367,13 +375,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) @@ -499,14 +515,16 @@ def _add_error(self, msg, serialized_data): ) 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, }, @@ -526,7 +544,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, ) @@ -703,15 +721,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(u"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 6f83892a9..ead93f9df 100644 --- a/src/Products/urban/browser/urbaneventviews.py +++ b/src/Products/urban/browser/urbaneventviews.py @@ -1476,6 +1476,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"] @@ -1487,6 +1488,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", @@ -1502,6 +1504,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 b802e0f84..07b71b2dd 100644 --- a/src/Products/urban/locales/fr/LC_MESSAGES/urban.po +++ b/src/Products/urban/locales/fr/LC_MESSAGES/urban.po @@ -382,6 +382,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 697c92483..2d5bcb5fd 100644 --- a/src/Products/urban/locales/urban-manual.pot +++ b/src/Products/urban/locales/urban-manual.pot @@ -1725,3 +1725,5 @@ msgstr "" msgid "NOTIF_LIBRE_SANS_REPONSE_2_EME_INSTANCE" msgstr "" +msgid "PM_EP_COURRIER_COMMUNE" +msgstr "" diff --git a/src/Products/urban/locales/urban.pot b/src/Products/urban/locales/urban.pot index dbf27a9f5..ca358ed48 100644 --- a/src/Products/urban/locales/urban.pot +++ b/src/Products/urban/locales/urban.pot @@ -5968,3 +5968,6 @@ msgstr "" msgid "PM_PROROGATION_COURRIER_COMMUNE" msgstr "" + +msgid "PM_EP_COURRIER_COMMUNE" +msgstr ""