コード例 #1
0
    def post(self, analysis_id):
        analysis_id = int(analysis_id.split("/")[0])
        analysis_id_sent = int(self.get_argument('analysis_id'))
        action = self.get_argument('action')

        if analysis_id != analysis_id_sent or action != 'delete_analysis':
            raise QiitaPetAuthorizationError(
                self.current_user.id,
                'analysis/results/%d-delete' % analysis_id)

        analysis = Analysis(analysis_id)
        analysis_name = analysis.name
        check_analysis_access(self.current_user, analysis)

        try:
            Analysis.delete(analysis_id)
            msg = ("Analysis <b><i>%s</i></b> has been deleted." %
                   (analysis_name))
            level = "success"
        except Exception as e:
            e = str(e)
            msg = ("Couldn't remove <b><i>%s</i></b> analysis: %s" %
                   (analysis_name, e))
            level = "danger"
            LogEntry.create(
                'Runtime',
                "Couldn't remove analysis ID %d: %s" % (analysis_id, e))

        self.redirect(u"/analysis/show/?level=%s&message=%s" % (level, msg))
コード例 #2
0
ファイル: analysis_handlers.py プロジェクト: yimsea/qiita
    def post(self, analysis_id):
        analysis_id = int(analysis_id.split("/")[0])
        analysis_id_sent = int(self.get_argument('analysis_id'))
        action = self.get_argument('action')

        if analysis_id != analysis_id_sent or action != 'delete_analysis':
            raise QiitaPetAuthorizationError(
                self.current_user.id,
                'analysis/results/%d-delete' % analysis_id)

        analysis = Analysis(analysis_id)
        analysis_name = analysis.name
        check_analysis_access(self.current_user, analysis)

        try:
            Analysis.delete(analysis_id)
            msg = ("Analysis <b><i>%s</i></b> has been deleted." % (
                analysis_name))
            level = "success"
        except Exception as e:
            e = str(e)
            msg = ("Couldn't remove <b><i>%s</i></b> analysis: %s" % (
                analysis_name, e))
            level = "danger"
            LogEntry.create('Runtime', "Couldn't remove analysis ID %d: %s" %
                            (analysis_id, e))

        self.redirect(u"/analysis/show/?level=%s&message=%s" % (level, msg))
コード例 #3
0
ファイル: test_analysis.py プロジェクト: MarkBruns/qiita
    def test_delete(self):
        # successful delete
        total_analyses = get_count("qiita.analysis")
        Analysis.delete(1)
        self.assertEqual(total_analyses - 1, get_count("qiita.analysis"))

        # no possible to delete
        with self.assertRaises(QiitaDBUnknownIDError):
            Analysis.delete(total_analyses + 1)
コード例 #4
0
ファイル: analysis_handlers.py プロジェクト: yimsea/qiita
    def post(self):
        analysis_id = int(self.get_argument('analysis_id'))
        analysis = Analysis(analysis_id)
        analysis_name = analysis.name

        check_analysis_access(self.current_user, analysis)

        try:
            Analysis.delete(analysis_id)
            msg = ("Analysis <b><i>%s</i></b> has been deleted." % (
                analysis_name))
            level = "success"
        except Exception as e:
            e = str(e)
            msg = ("Couldn't remove <b><i>%s</i></b> analysis: %s" % (
                analysis_name, e))
            level = "danger"
            LogEntry.create('Runtime', "Couldn't remove analysis ID %d: %s" %
                            (analysis_id, e))

        self.redirect(u"/analysis/show/?level=%s&message=%s" % (level, msg))
コード例 #5
0
    def post(self):
        analysis_id = int(self.get_argument('analysis_id'))
        analysis = Analysis(analysis_id)
        analysis_name = analysis.name

        check_analysis_access(self.current_user, analysis)

        try:
            Analysis.delete(analysis_id)
            msg = ("Analysis <b><i>%s</i></b> has been deleted." %
                   (analysis_name))
            level = "success"
        except Exception as e:
            e = str(e)
            msg = ("Couldn't remove <b><i>%s</i></b> analysis: %s" %
                   (analysis_name, e))
            level = "danger"
            LogEntry.create(
                'Runtime',
                "Couldn't remove analysis ID %d: %s" % (analysis_id, e))

        self.redirect(u"/analysis/show/?level=%s&message=%s" % (level, msg))