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 c21cda4
Show file tree
Hide file tree
Showing 2 changed files with 13 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
23 changes: 11 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 Expand Up @@ -509,6 +507,7 @@ def _rest_getItemCreationAvailableData(self):
u"itemTags",
]
configs_url = "{0}/@users/{1}?extra_include=configs".format(
self.url,
self.url,
self.username,
)
Expand Down

0 comments on commit c21cda4

Please sign in to comment.