|  | @@ -501,7 +501,7 @@ class ContentApi(object):
 | 
	
		
			
			| 501 | 501 |  
 | 
	
		
			
			| 502 | 502 |      def mark_read(self, content: Content,
 | 
	
		
			
			| 503 | 503 |                    read_datetime: datetime=None,
 | 
	
		
			
			| 504 |  | -                  do_flush=True) -> Content:
 | 
	
		
			
			|  | 504 | +                  do_flush: bool=True, recursive: bool=True) -> Content:
 | 
	
		
			
			| 505 | 505 |  
 | 
	
		
			
			| 506 | 506 |          assert self._user
 | 
	
		
			
			| 507 | 507 |          assert content
 | 
	
	
		
			
			|  | @@ -521,8 +521,23 @@ class ContentApi(object):
 | 
	
		
			
			| 521 | 521 |          for revision in viewed_revisions:
 | 
	
		
			
			| 522 | 522 |              revision.read_by[self._user] = read_datetime
 | 
	
		
			
			| 523 | 523 |  
 | 
	
		
			
			| 524 |  | -        for child in content.get_valid_children():
 | 
	
		
			
			| 525 |  | -            self.mark_read(child, read_datetime=read_datetime, do_flush=False)
 | 
	
		
			
			|  | 524 | +        if recursive:
 | 
	
		
			
			|  | 525 | +            # mark read :
 | 
	
		
			
			|  | 526 | +            # - all children
 | 
	
		
			
			|  | 527 | +            # - parent stuff (if you mark a comment as read,
 | 
	
		
			
			|  | 528 | +            #                 then you have seen the parent)
 | 
	
		
			
			|  | 529 | +            # - parent comments
 | 
	
		
			
			|  | 530 | +            for child in content.get_valid_children():
 | 
	
		
			
			|  | 531 | +                self.mark_read(child, read_datetime=read_datetime,
 | 
	
		
			
			|  | 532 | +                               do_flush=False)
 | 
	
		
			
			|  | 533 | +
 | 
	
		
			
			|  | 534 | +            if ContentType.Comment == content.type:
 | 
	
		
			
			|  | 535 | +                self.mark_read(content.parent, read_datetime=read_datetime,
 | 
	
		
			
			|  | 536 | +                               do_flush=False, recursive=False)
 | 
	
		
			
			|  | 537 | +                for comment in content.parent.get_comments():
 | 
	
		
			
			|  | 538 | +                    if comment != content:
 | 
	
		
			
			|  | 539 | +                        self.mark_read(comment, read_datetime=read_datetime,
 | 
	
		
			
			|  | 540 | +                                       do_flush=False, recursive=False)
 | 
	
		
			
			| 526 | 541 |  
 | 
	
		
			
			| 527 | 542 |          if do_flush:
 | 
	
		
			
			| 528 | 543 |              self.flush()
 | 
	
	
		
			
			|  | @@ -569,9 +584,22 @@ class ContentApi(object):
 | 
	
		
			
			| 569 | 584 |              content.revision_type = action_description
 | 
	
		
			
			| 570 | 585 |  
 | 
	
		
			
			| 571 | 586 |          if do_flush:
 | 
	
		
			
			|  | 587 | +            # INFO - 2015-09-03 - D.A.
 | 
	
		
			
			|  | 588 | +            # There are 2 flush because of the use
 | 
	
		
			
			|  | 589 | +            # of triggers for content creation
 | 
	
		
			
			|  | 590 | +            #
 | 
	
		
			
			|  | 591 | +            # (when creating a content, actually this is an insert of a new
 | 
	
		
			
			|  | 592 | +            # revision in content_revisions ; so the mark_read operation need
 | 
	
		
			
			|  | 593 | +            # to get full real data from database before to be prepared.
 | 
	
		
			
			|  | 594 | +
 | 
	
		
			
			| 572 | 595 |              DBSession.add(content)
 | 
	
		
			
			| 573 | 596 |              DBSession.flush()
 | 
	
		
			
			| 574 | 597 |  
 | 
	
		
			
			|  | 598 | +            # TODO - 2015-09-03 - D.A. - Do not use triggers
 | 
	
		
			
			|  | 599 | +            # We should create a new ContentRevisionRO object instead of Content
 | 
	
		
			
			|  | 600 | +            # This would help managing view/not viewed status
 | 
	
		
			
			|  | 601 | +            self.mark_read(content, do_flush=True)
 | 
	
		
			
			|  | 602 | +
 | 
	
		
			
			| 575 | 603 |          if do_notify:
 | 
	
		
			
			| 576 | 604 |              self.do_notify(content)
 | 
	
		
			
			| 577 | 605 |  
 |