def post(self): """Handles POST requests.""" exploration_id = self.payload.get('exploration_id') forked_exploration = Exploration.get(exploration_id) if not forked_exploration.is_demo: raise self.InvalidInputException('Exploration cannot be forked.') # Get the demo exploration as a YAML file, so that new states can be # created. yaml_content = exp_services.export_to_yaml(forked_exploration.id) title = 'Copy of %s' % forked_exploration.title category = forked_exploration.category new_exploration_id = exp_services.create_from_yaml( yaml_content, self.user_id, title, category) self.render_json({'explorationId': new_exploration_id})
def post(self): """Handles POST requests.""" title = self.payload.get('title') category = self.payload.get('category') if not title: raise self.InvalidInputException('No title supplied.') if not category: raise self.InvalidInputException('No category chosen.') yaml_content = self.request.get('yaml') if yaml_content and feconf.ALLOW_YAML_FILE_UPLOAD: exploration_id = exp_services.create_from_yaml( yaml_content, self.user_id, title, category) else: exploration_id = exp_services.create_new( self.user_id, title=title, category=category) self.render_json({'explorationId': exploration_id})