def require_editor(handler):
 def test_editor(self, exploration_id, escaped_state_name=None, **kwargs):
  'Gets the user and exploration id if the user can edit it.\n\n        Args:\n            self: the handler instance\n            exploration_id: the exploration id\n            escaped_state_name: the URL-escaped state name, if it exists\n            **kwargs: any other arguments passed to the handler\n\n        Returns:\n            The relevant handler, if the user is authorized to edit this\n            exploration.\n\n        Raises:\n            self.PageNotFoundException: if no such exploration or state exists.\n            self.UnauthorizedUserException: if the user exists but does not\n                have the right credentials.\n        '
  if (not self.user_id):
   self.redirect(current_user_services.create_login_url(self.request.uri))
   return
  if (self.username in config_domain.BANNED_USERNAMES.value):
   raise self.UnauthorizedUserException('You do not have the credentials to access this page.')
  try:
   exploration = exp_services.get_exploration_by_id(exploration_id)
  except:
   raise self.PageNotFoundException
  if (not rights_manager.Actor(self.user_id).can_edit(feconf.ACTIVITY_TYPE_EXPLORATION, exploration_id)):
   raise self.UnauthorizedUserException('You do not have the credentials to edit this exploration.', self.user_id)
  if (not escaped_state_name):
   return handler(self, exploration_id, **kwargs)
  state_name = utils.unescape_encoded_uri_component(escaped_state_name)
  if (state_name not in exploration.states):
   logging.error(('Could not find state: %s' % state_name))
   logging.error(('Available states: %s' % exploration.states.keys()))
   raise self.PageNotFoundException
  return handler(self, exploration_id, state_name, **kwargs)
 return test_editor

def require_editor ( handler ) : def test_editor ( self , exploration_id , escaped_state_name = None , ** kwargs ) : if ( not self . user_id ) : self . redirect ( current_user_services . create_login_url ( self . request . uri ) ) return if ( self . username in config_domain . BANNED_USERNAMES . value ) : raise self . UnauthorizedUserException ( 'You do not have the credentials to access this page.' ) try : exploration = exp_services . get_exploration_by_id ( exploration_id ) except : raise self . PageNotFoundException if ( not rights_manager . Actor ( self . user_id ) . can_edit ( feconf . ACTIVITY_TYPE_EXPLORATION , exploration_id ) ) : raise self . UnauthorizedUserException ( 'You do not have the credentials to edit this exploration.' , self . user_id ) if ( not escaped_state_name ) : return handler ( self , exploration_id , ** kwargs ) state_name = utils . unescape_encoded_uri_component ( escaped_state_name ) if ( state_name not in exploration . states ) : logging . error ( ( 'Could not find state: %s' % state_name ) ) logging . error ( ( 'Available states: %s' % exploration . states . keys ( ) ) ) raise self . PageNotFoundException return handler ( self , exploration_id , state_name , ** kwargs ) return test_editor
decorator that checks if the user can edit the given collection .