def _check_authorized(requesting_user, username, allow_staff=False):
 if (requesting_user.username != username):
  if ((not requesting_user.is_staff) or (not allow_staff)):
   raise UserNotAuthorized()

def _check_authorized ( requesting_user , username , allow_staff = False ) : if ( requesting_user . username != username ) : if ( ( not requesting_user . is_staff ) or ( not allow_staff ) ) : raise UserNotAuthorized ( )
helper method that raises usernotauthorized if requesting user is not owner user or is not staff if access to staff is given .