<s> """<STR_LIT>""" <EOL> from permission . conf import settings <EOL> from permission . logics . base import PermissionLogic <EOL> class OneselfPermissionLogic ( PermissionLogic ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , <EOL> any_permission = None , <EOL> change_permission = None , <EOL> delete_permission = None ) : <EOL> """<STR_LIT>""" <EOL> self . any_permission = any_permission <EOL> self . change_permission = change_permission <EOL> self . delete_permission = delete_permission <EOL> if self . any_permission is None : <EOL> self . any_permission = settings . PERMISSION_DEFAULT_OSPL_ANY_PERMISSION <EOL> if self . change_permission is None : <EOL> self . change_permission = settings . PERMISSION_DEFAULT_OSPL_CHANGE_PERMISSION <EOL> if self . delete_permission is None : <EOL> self . delete_permission = settings . PERMISSION_DEFAULT_OSPL_DELETE_PERMISSION <EOL> def has_perm ( self , user_obj , perm , obj = None ) : <EOL> """<STR_LIT>""" <EOL> if not user_obj . is_authenticated ( ) : <EOL> return False <EOL> change_permission = self . get_full_permission_string ( '<STR_LIT>' ) <EOL> delete_permission = self . get_full_permission_string ( '<STR_LIT>' ) <EOL> if obj is None : <EOL> if self . any_permission : <EOL> return True <EOL> if self . change_permission and perm == change_permission : <EOL> return True <EOL> if self . delete_permission and perm == delete_permission : <EOL> return True <EOL> return False <EOL> elif user_obj . is_active : <EOL> if obj == user_obj : <EOL> if self . any_permission : <EOL> return True <EOL> if ( self . change_permission and <EOL> perm == change_permission ) : <EOL> return True <EOL> if ( self . delete_permission and <EOL> perm == delete_permission ) : <EOL> return True <EOL> return False </s>
