diff --git a/news/URB-3151.feature b/news/URB-3151.feature new file mode 100644 index 000000000..4cb1fa188 --- /dev/null +++ b/news/URB-3151.feature @@ -0,0 +1,4 @@ +Use imio.pm.wsclient 2.x version (REST). +[aduchene] +Add `get_last_plonemeeting_date`, `get_last_college_date` and `get_last_college_date` to CODT_BaseBuildLicence. +[aduchene] \ No newline at end of file diff --git a/src/Products/urban/content/licence/CODT_BaseBuildLicence.py b/src/Products/urban/content/licence/CODT_BaseBuildLicence.py index 812b6522a..efe95e467 100644 --- a/src/Products/urban/content/licence/CODT_BaseBuildLicence.py +++ b/src/Products/urban/content/licence/CODT_BaseBuildLicence.py @@ -16,6 +16,7 @@ from AccessControl import ClassSecurityInfo from Products.urban.widget.select2widget import MultiSelect2Widget from Products.Archetypes.atapi import * +from zope.component import getMultiAdapter from zope.interface import implements from Products.MasterSelectWidget.MasterBooleanWidget import MasterBooleanWidget from Products.ATReferenceBrowserWidget.ATReferenceBrowserWidget import ( @@ -740,6 +741,35 @@ def list_patrimony_types(self): ) return DisplayList(vocabulary) + def get_last_plonemeeting_date(self, + event=interfaces.ISimpleCollegeEvent, + item_portal_type="MeetingItemCollege", + decided_states=('accepted', 'accepted_but_modified', 'accepted_and_returned')): + """ + Get the last date of a PloneMeeting meeting for a given event. + """ + meeting_event = self.getLastEvent(event) + if not meeting_event: + return + ws4pmSettings = getMultiAdapter( + (api.portal.get(), self.REQUEST), name="ws4pmclient-settings" + ) + return ws4pmSettings._rest_getDecidedMeetingDate( + {"externalIdentifier": meeting_event.UID()}, + item_portal_type=item_portal_type, + decided_states=decided_states, + ) + + def get_last_college_date(self, + event=interfaces.ISimpleCollegeEvent, + decided_states=('accepted', 'accepted_but_modified', 'accepted_and_returned')): + return self.get_last_plonemeeting_date(event=event, item_portal_type='MeetingItemCollege', decided_states=decided_states) + + def get_last_council_date(self, + event=interfaces.ISimpleCollegeEvent, + decided_states=('accepted', 'accepted_but_modified', 'accepted_and_returned')): + return self.get_last_plonemeeting_date(event=event, item_portal_type='MeetingItemCouncil', decided_states=decided_states) + # end of class CODT_BaseBuildLicence diff --git a/src/Products/urban/indexes.py b/src/Products/urban/indexes.py index dccac6245..c7b8b9606 100644 --- a/src/Products/urban/indexes.py +++ b/src/Products/urban/indexes.py @@ -29,7 +29,7 @@ from plone import api from plone.indexer import indexer -from suds import WebFault +from requests.exceptions import RequestException from zope.component import queryAdapter from zope.interface import Interface @@ -244,7 +244,7 @@ def genericlicence_decisiondate(licence): if decision_event: try: linked_pm_items = get_ws_meetingitem_infos(decision_event) - except WebFault: + except RequestException: catalog = api.portal.get_tool("portal_catalog") brain = catalog(UID=licence.UID()) if brain and brain[0].getDecisionDate: diff --git a/src/Products/urban/utils.py b/src/Products/urban/utils.py index 2b964693e..fe4907ef9 100644 --- a/src/Products/urban/utils.py +++ b/src/Products/urban/utils.py @@ -230,11 +230,11 @@ def get_ws_meetingitem_infos(urban_event, extra_attributes=False): ws4pmSettings = getMultiAdapter( (portal_state.portal(), request), name="ws4pmclient-settings" ) - items = ws4pmSettings._soap_searchItems( + items = ws4pmSettings._rest_searchItems( {"externalIdentifier": urban_event.UID()} ) if extra_attributes and items: - items = ws4pmSettings._soap_getItemInfos( + items = ws4pmSettings._rest_getItemInfos( {"UID": items[0].UID, "showExtraInfos": True} ) return items