#NEWLINE# def add_viewer( self , viewer , responsible = None , roles = None ) : #NEWLINE# #INDENT# roles = ( responsible or DEFAULT_ROLE ) #NEWLINE# ( otp , created ) = OwnerToPermission . objects . get_or_create ( object_id = self . pk , content_type = ContentType . objects . get_for_model ( self ) , owner_object_id = viewer . pk , owner_content_type = ContentType . objects . get_for_model ( viewer ) , permission = get_view_permission ( ) , defaults = { #NEWLINE# #INDENT# 'responsible' : responsible , #NEWLINE# 'roles' : roles , #NEWLINE# #UNINDENT# } ) #NEWLINE# if ( ( not created ) and ( otp . roles != roles ) ) : #NEWLINE# #INDENT# otp . roles |= roles #NEWLINE# otp . save ( )