Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions news/URB-3640.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Handle PM_EP_COURRIER_COMMUNE notification
[WBoudabous]
90 changes: 52 additions & 38 deletions src/Products/urban/browser/cron/notice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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:
Expand All @@ -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",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must remain unicode

"%s",
custom_exc,
)
self._notify_import_error(
Expand Down Expand Up @@ -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",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must remain unicode

"%s",
custom_exc,
)
self._notify_import_error(
Expand All @@ -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(),
)

Expand All @@ -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):
Expand All @@ -166,7 +163,7 @@ def _get_notice_notifications(self):
except Exception as exc:
custom_exc = FailedGettingRecentNotificationsException(exc)
logger.exception(
u"%s",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must remain unicode

"%s",
custom_exc,
)
self._notify_import_error(
Expand All @@ -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,
)

Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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,
},
Expand All @@ -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,
)

Expand Down Expand Up @@ -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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must remain unicode

"Décision: {}".format(self.notification.decision_code)
)

@property
Expand Down Expand Up @@ -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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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):
Expand Down
3 changes: 3 additions & 0 deletions src/Products/urban/browser/urbaneventviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand All @@ -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",
Expand All @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions src/Products/urban/locales/fr/LC_MESSAGES/urban.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Comment thread
mpeeters marked this conversation as resolved.
msgstr "Demande d'organisation d'une enquête publique - Plans Modificatifs"

#: ../browser/offdays_settings.py:47
msgid "Date"
msgstr "Date"
Expand Down
1 change: 1 addition & 0 deletions src/Products/urban/locales/urban-manual.pot
Original file line number Diff line number Diff line change
Expand Up @@ -1697,4 +1697,5 @@ msgid "DECISION_GESPER_2_EME_INSTANCE"
msgstr ""

msgid "PM_ENVOI_RS_HD_SFD_COMMUNE"
msgid "PM_EP_COURRIER_COMMUNE"
msgstr ""
2 changes: 2 additions & 0 deletions src/Products/urban/locales/urban.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5931,3 +5931,5 @@ msgstr ""

msgid "PM_ENVOI_RS_HD_SFD_COMMUNE"
msgstr ""
msgid "PM_EP_COURRIER_COMMUNE"
msgstr ""