-
Notifications
You must be signed in to change notification settings - Fork 0
URB-3640: implement pm ep courrier commune notification #570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2.9.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Handle PM_EP_COURRIER_COMMUNE notification | ||
| [WBoudabous] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Must remain unicode |
||
| "%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", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Must remain unicode |
||
| "%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"<p>${msg} for informations: ${data}</p>", | ||
| "<p>${msg} for informations: ${data}</p>", | ||
| mapping={ | ||
| "msg": msg, | ||
| "data": u", ".join( | ||
| [u"{0}: {1}".format(k, v) for k, v in serialized_data.items()] | ||
|
Comment on lines
-449
to
-453
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Must remain unicode |
||
| "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) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Must remain unicode |
||
| "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) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Must remain unicode |
||
| ) | ||
| self.event.setDescription("Décision: {}".format(decision_code)) | ||
|
|
||
| @property | ||
| def desired_licence_state(self): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5931,3 +5931,5 @@ msgstr "" | |
|
|
||
| msgid "PM_ENVOI_RS_HD_SFD_COMMUNE" | ||
| msgstr "" | ||
| msgid "PM_EP_COURRIER_COMMUNE" | ||
| msgstr "" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must remain unicode