Skip to content

Commit

Permalink
Improve _rest_getDecidedMeetingDate
Browse files Browse the repository at this point in the history
  • Loading branch information
duchenean committed Oct 30, 2024
1 parent 57a2933 commit a5f0f8a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changelog
2.0.0b3 (unreleased)
--------------------

- Nothing changed yet.
- Improve `_rest_getDecidedMeetingDate` to make only one request.
[aduchene]


2.0.0b2 (2024-10-16)
Expand Down
22 changes: 10 additions & 12 deletions src/imio/pm/wsclient/browser/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,24 +419,22 @@ def _rest_getDecidedMeetingDate(self,
It returns a datetime object if a meeting has been found, or None otherwise.
TODO: handle decided_states correctly, fetching decided states from PloneMeeting configuration
"""
brains = self._rest_searchItems(data)
if not brains:
query = {
'extra_include': 'meeting,linked_items',
'extra_include_linked_items_mode': 'every_successors',
'extra_include_linked_items_extra_include': 'meeting',
}
query.update(data)
items = self._rest_searchItems(query)
if not items:
return # Item has been deleted or has not been sent to PloneMeeting
item = self._rest_getItemInfos(
{"UID": brains[0]['UID'], "showExtraInfos": True,
'extra_include': 'meeting,linked_items',
'extra_include_meeting_additional_values': '*',
'extra_include_linked_items_mode': 'every_successors'}
)[0]
item = items[0]
if item_portal_type == item["@type"] and item['review_state'] in decided_states:
return datetime.strptime(item['extra_include_meeting']['date'], "%Y-%m-%dT%H:%M:%S")
elif item['extra_include_linked_items']:
for linked_item in item['extra_include_linked_items']:
if item_portal_type == linked_item["@type"] and linked_item['review_state'] in decided_states:
item = self._rest_getItemInfos(
{"UID": linked_item['UID'], "showExtraInfos": True, 'extra_include': 'meeting'}
)[0]
return datetime.strptime(item['extra_include_meeting']['date'], "%Y-%m-%dT%H:%M:%S")
return datetime.strptime(linked_item['extra_include_meeting']['date'], "%Y-%m-%dT%H:%M:%S")


def _rest_getItemTemplate(self, data):
Expand Down

0 comments on commit a5f0f8a

Please sign in to comment.