@@ -491,6 +491,46 @@ def update_page(self, parent_id, page_id, title, body, type='page',
491
491
492
492
return self .put ('rest/api/content/{0}' .format (page_id ), data = data )
493
493
494
+ def append_page (self , parent_id , page_id , title , append_body , type = 'page' ,
495
+ minor_edit = False ):
496
+ """
497
+ Append body to page if already exist
498
+ :param parent_id:
499
+ :param page_id:
500
+ :param title:
501
+ :param append_body:
502
+ :param type:
503
+ :param minor_edit: Indicates whether to notify watchers about changes.
504
+ If False then notifications will be sent.
505
+ :return:
506
+ """
507
+ log .info ('Updating {type} "{title}"' .format (title = title , type = type ))
508
+
509
+ if self .is_page_content_is_already_updated (page_id , append_body ):
510
+ return self .get_page_by_id (page_id )
511
+ else :
512
+ version = self .history (page_id )['lastUpdated' ]['number' ] + 1
513
+ previous_body = (self .get_page_by_id (page_id , expand = 'body.storage' ).get ('body' ) or {}).get (
514
+ 'storage' ).get (
515
+ 'value' )
516
+ previous_body = previous_body .replace ('ó' , u'ó' )
517
+ body = previous_body + append_body
518
+ data = {
519
+ 'id' : page_id ,
520
+ 'type' : type ,
521
+ 'title' : title ,
522
+ 'body' : {'storage' : {
523
+ 'value' : body ,
524
+ 'representation' : 'storage' }},
525
+ 'version' : {'number' : version ,
526
+ 'minorEdit' : minor_edit }
527
+ }
528
+
529
+ if parent_id :
530
+ data ['ancestors' ] = [{'type' : 'page' , 'id' : parent_id }]
531
+
532
+ return self .put ('rest/api/content/{0}' .format (page_id ), data = data )
533
+
494
534
def update_or_create (self , parent_id , title , body ):
495
535
"""
496
536
Update page or create a page if it is not exists
0 commit comments