Skip to content

Conversation

@djachkov
Copy link
Contributor

This is a quick fix for an issue. I think we should make a review of the advanced_mode features for all methods.
It not the first time, when some troubles appear because of that.

.get('body') or {})
.get('storage') or {})
if self.advanced_mode:
confluence_content = (((self.get_page_by_id(page_id, expand='body.storage').json() or {})

Choose a reason for hiding this comment

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

Hi!
maybe better will be something like that:

page = self.get_page_by_id(page_id, expand='body.storage') 
page = page.json() if self.advanced_mode else page
confluence_content = (((page or {})
              .get('body') or {})
              .get('storage') or {})

it helps to avoid code duplication and makes code more readable.

else:
try:
version = self.history(page_id)['lastUpdated']['number'] + 1
if self.advanced_mode:

Choose a reason for hiding this comment

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

and the same here

page_history = self.history(page_id).json() if self.advanced_mode else self.history(page_id)
version = page_history['lastUpdated']['number'] + 1

@gonchik gonchik merged commit 52df199 into atlassian-api:master Jan 24, 2020
@gonchik
Copy link
Member

gonchik commented Jan 24, 2020

@mikitachab Would you like to provide a some PR for refactoring ? :)

@mikitachab
Copy link

@gonchik no problem, I will find some time and do it later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants