Esempio n. 1
0
    def post(self, exploration_id):
        """Handles POST requests."""
        current_version = self.normalized_payload.get('current_version')
        revert_to_version = self.normalized_payload.get('revert_to_version')

        if revert_to_version >= current_version:
            raise self.InvalidInputException(
                'Cannot revert to version %s from version %s.' %
                (revert_to_version, current_version))

        exp_services.discard_draft(exploration_id, self.user_id)
        exp_services.revert_exploration(self.user_id, exploration_id,
                                        current_version, revert_to_version)
        self.render_json({})
Esempio n. 2
0
    def post(self, exploration_id):
        """Handles POST requests."""
        current_version = self.payload.get('current_version')
        revert_to_version = self.payload.get('revert_to_version')

        if not isinstance(revert_to_version, int):
            raise self.InvalidInputException(
                'Expected an integer version to revert to; received %s.' %
                revert_to_version)
        if not isinstance(current_version, int):
            raise self.InvalidInputException(
                'Expected an integer current version; received %s.' %
                current_version)

        if revert_to_version < 1 or revert_to_version >= current_version:
            raise self.InvalidInputException(
                'Cannot revert to version %s from version %s.' %
                (revert_to_version, current_version))

        exp_services.discard_draft(exploration_id, self.user_id)
        exp_services.revert_exploration(self.user_id, exploration_id,
                                        current_version, revert_to_version)
        self.render_json({})
Esempio n. 3
0
    def post(self, exploration_id):
        """Handles POST requests."""
        current_version = self.payload.get('current_version')
        revert_to_version = self.payload.get('revert_to_version')

        if not isinstance(revert_to_version, int):
            raise self.InvalidInputException(
                'Expected an integer version to revert to; received %s.' %
                revert_to_version)
        if not isinstance(current_version, int):
            raise self.InvalidInputException(
                'Expected an integer current version; received %s.' %
                current_version)

        if revert_to_version < 1 or revert_to_version >= current_version:
            raise self.InvalidInputException(
                'Cannot revert to version %s from version %s.' %
                (revert_to_version, current_version))

        exp_services.discard_draft(exploration_id, self.user_id)
        exp_services.revert_exploration(
            self.user_id, exploration_id, current_version, revert_to_version)
        self.render_json({})
Esempio n. 4
0
 def post(self, exploration_id):
     """Handles POST request for discarding draft changes."""
     exp_services.discard_draft(exploration_id, self.user_id)
     self.render_json({})
Esempio n. 5
0
 def post(self, exploration_id):
     """Handles POST request for discarding draft changes."""
     exp_services.discard_draft(exploration_id, self.user_id)
     self.render_json({})