Пример #1
0
    def post(self, exp_id):
        """Handles POST requests."""
        exp_issue_object = self.normalized_payload.get('exp_issue_object')
        exp_version = self.normalized_payload.get('exp_version')

        exp_issues = stats_services.get_exp_issues(exp_id, exp_version)
        if exp_issues is None:
            raise self.PageNotFoundException('Invalid exploration ID %s' %
                                             (exp_id))

        # Check that the passed in issue actually exists in the exploration
        # issues instance.
        issue_to_remove = None
        for issue in exp_issues.unresolved_issues:
            if issue == exp_issue_object:
                issue_to_remove = issue
                break

        if not issue_to_remove:
            raise self.PageNotFoundException(
                'Exploration issue does not exist in the list of issues for '
                'the exploration with ID %s' % exp_id)

        # Remove the issue from the unresolved issues list.
        exp_issues.unresolved_issues.remove(issue_to_remove)

        # Update the exploration issues instance and delete the playthrough
        # instances.
        stats_services.delete_playthroughs_multi(
            issue_to_remove.playthrough_ids)
        stats_services.save_exp_issues_model(exp_issues)

        self.render_json({})
Пример #2
0
 def get(self, exp_id):
     """Handles GET requests."""
     exp_version = self.request.get('exp_version')
     exp_issues = stats_services.get_exp_issues(exp_id, exp_version)
     if exp_issues is None:
         raise self.PageNotFoundException(
             'Invalid exploration ID %s' % (exp_id))
     unresolved_issues = []
     for issue in exp_issues.unresolved_issues:
         if issue.is_valid:
             unresolved_issues.append(issue)
     exp_issues.unresolved_issues = unresolved_issues
     exp_issues_dict = exp_issues.to_dict()
     self.render_json(exp_issues_dict['unresolved_issues'])
Пример #3
0
    def post(self, exploration_id):
        """Handles POST requests. Appends to existing list of playthroughs or
        deletes it if already full.

        Args:
            exploration_id: str. The ID of the exploration.
        """
        issue_schema_version = self.normalized_payload.get(
            'issue_schema_version')

        playthrough = self.normalized_payload.get('playthrough_data')

        exp_issues = stats_services.get_exp_issues(exploration_id,
                                                   playthrough.exp_version)

        if stats_services.assign_playthrough_to_corresponding_issue(
                playthrough, exp_issues, issue_schema_version):
            stats_services.save_exp_issues_model(exp_issues)
        self.render_json({})
Пример #4
0
    def post(self, exploration_id):
        """Handles POST requests. Appends to existing list of playthroughs or
        deletes it if already full.

        Args:
            exploration_id: str. The ID of the exploration.
        """
        issue_schema_version = self.payload.get('issue_schema_version')
        if issue_schema_version is None:
            raise self.InvalidInputException('missing issue_schema_version')

        playthrough_data = self.payload.get('playthrough_data')
        try:
            playthrough = stats_domain.Playthrough.from_dict(playthrough_data)
        except utils.ValidationError as e:
            raise self.InvalidInputException(e)

        exp_issues = stats_services.get_exp_issues(exploration_id,
                                                   playthrough.exp_version)

        if stats_services.assign_playthrough_to_corresponding_issue(
                playthrough, exp_issues, issue_schema_version):
            stats_services.save_exp_issues_model(exp_issues)
        self.render_json({})