#NEWLINE# def has_permission( user , permission_name ) : #NEWLINE# #INDENT# if ( permission_name and user . is_superuser ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# role = get_user_role ( user ) #NEWLINE# if ( role and ( permission_name in role . permission_names_list ( ) ) ) : #NEWLINE# #INDENT# permission = get_permission ( permission_name ) #NEWLINE# if ( permission in user . user_permissions . all ( ) ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# #UNINDENT# return False