#NEWLINE# @ role . setter #NEWLINE# def role( self , role ) : #NEWLINE# #INDENT# 'Set administrative role for this account\n\n        :param string role: the role to set\n        ' #NEWLINE# if ( ( role is None ) or ( self . group == role ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# events . raiseEvent ( 'RoleChanged' , self , role ) #NEWLINE# self . groups . clear ( ) #NEWLINE# if ( role == 'SuperAdmins' ) : #NEWLINE# #INDENT# self . is_superuser = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if self . is_superuser : #NEWLINE# #INDENT# ObjectAccess . objects . filter ( user = self ) . delete ( ) #NEWLINE# #UNINDENT# self . is_superuser = False #NEWLINE# try : #NEWLINE# #INDENT# self . groups . add ( Group . objects . get ( name = role ) ) #NEWLINE# #UNINDENT# except Group . DoesNotExist : #NEWLINE# #INDENT# self . groups . add ( Group . objects . get ( name = 'SimpleUsers' ) ) #NEWLINE# #UNINDENT# if ( ( self . group != 'SimpleUsers' ) and ( not self . can_access ( self ) ) ) : #NEWLINE# #INDENT# from modoboa.lib.permissions import grant_access_to_object #NEWLINE# grant_access_to_object ( self , role ) #NEWLINE# #UNINDENT# #UNINDENT# self . save ( )