Skip to content

Commit 7af698e

Browse files
author
Gonchik Tsymzhitov
committed
Add parent condition
1 parent 585112e commit 7af698e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

atlassian/confluence.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,13 @@ def get_parent_content_id(self, page_id):
108108
:type page_id: str
109109
:return:
110110
"""
111-
parent_content_id = ((self.get_page_by_id(page_id=page_id, expand='ancestors').get('ancestors') or {})[-1].get(
112-
'id') or None)
111+
parent_content_id = None
112+
try:
113+
parent_content_id = (
114+
(self.get_page_by_id(page_id=page_id, expand='ancestors').get('ancestors') or {})[-1].get(
115+
'id') or None)
116+
except Exception as e:
117+
log.error(e)
113118
return parent_content_id
114119

115120
def get_page_space(self, page_id):
@@ -1186,7 +1191,7 @@ def update_or_create(self, parent_id, title, body, representation='storage', min
11861191

11871192
if self.page_exists(space, title):
11881193
page_id = self.get_page_id(space, title)
1189-
parent_id = self.get_parent_content_id(page_id)
1194+
parent_id = parent_id if parent_id is not None else self.get_parent_content_id(page_id)
11901195
result = self.update_page(parent_id=parent_id, page_id=page_id, title=title, body=body,
11911196
representation=representation, minor_edit=minor_edit,
11921197
version_comment=version_comment)

0 commit comments

Comments
 (0)