コード例 #1
0
 def test_list_reports(self):
     db_spam_report.create(self.revision_id, self.user2.id,
                           "This is a report")
     db_review.update(
         review_id=self.review["id"],
         drafted=self.review["is_draft"],
         text="Updated Review",
     )
     self.review = db_review.get_by_id(self.review["id"])
     db_spam_report.create(self.review["last_revision"]["id"],
                           self.user1.id,
                           "This is again a report on the updated review")
     # two reports on the old revision and one on the new revision.
     reports, count = db_spam_report.list_reports(
         review_id=self.review["id"])  # pylint: disable=unused-variable
     self.assertEqual(count, 3)
     # get all reports by a user.
     reports, count = db_spam_report.list_reports(user_id=self.user2.id)
     self.assertEqual(count, 1)
     # archive and include all archived reports.
     # there must be two reports including the archived one.
     db_spam_report.archive(self.user1.id,
                            self.review["last_revision"]["id"])
     reports, count = db_spam_report.list_reports(inc_archived=True)
     self.assertEqual(count, 3)
     # there must be one reports excluding the archived one.
     reports, count = db_spam_report.list_reports(inc_archived=False)
     self.assertEqual(count, 2)
コード例 #2
0
def archive(user_id, revision_id):
    report = db_spam_report.get(user_id, revision_id)
    if not report:
        raise NotFound("Can't find the specified report.")

    db_spam_report.archive(user_id, revision_id)
    flash(gettext("Report has been archived."), 'success')
    return redirect(url_for('.index'))
コード例 #3
0
ファイル: reports.py プロジェクト: metabrainz/critiquebrainz
def archive(user_id, revision_id):
    report = db_spam_report.get(user_id, revision_id)
    if not report:
        raise NotFound("Can't find the specified report.")

    db_spam_report.archive(user_id, revision_id)
    flash(gettext("Report has been archived."), 'success')
    return redirect(url_for('.index'))
コード例 #4
0
ファイル: review.py プロジェクト: pulkit6559/critiquebrainz
def hide(id):
    review = get_review_or_404(id)
    if review["is_hidden"]:
        flash.info(gettext("Review is already hidden."))
        return redirect(url_for('.entity', id=review["id"]))

    form = AdminActionForm()
    if form.validate_on_submit():
        db_review.set_hidden_state(review["id"], is_hidden=True)
        db_moderation_log.create(admin_id=current_user.id, action=ACTION_HIDE_REVIEW,
                                 reason=form.reason.data, review_id=review["id"])
        review_reports, count = db_spam_report.list_reports(review_id=review["id"])  # pylint: disable=unused-variable
        for report in review_reports:
            db_spam_report.archive(report["user_id"], report["revision_id"])
        flash.success(gettext("Review has been hidden."))
        return redirect(url_for('.entity', id=review["id"]))

    return render_template('log/action.html', review=review, form=form, action=ACTION_HIDE_REVIEW)
コード例 #5
0
 def test_list_reports(self):
     report1 = db_spam_report.create(self.revision_id, self.user2.id, "This is a report")
     self.review.update(text="Updated Review")
     report2 = db_spam_report.create(self.review.last_revision.id, self.user1.id, "This is again a report on the updated review")
     # two reports on the old revision and one on the new revision.
     reports, count = db_spam_report.list_reports(review_id=self.review.id)
     self.assertEqual(count, 3)
     # get all reports by a user.
     reports, count = db_spam_report.list_reports(user_id=self.user2.id)
     self.assertEqual(count, 1)
     # archive and include all archived reports.
     # there must be two reports including the archived one.
     db_spam_report.archive(self.user1.id, self.review.last_revision.id)
     reports, count = db_spam_report.list_reports(inc_archived=True)
     self.assertEqual(count, 3)
     # there must be one reports excluding the archived one.
     reports, count = db_spam_report.list_reports(inc_archived=False)
     self.assertEqual(count, 2)
コード例 #6
0
ファイル: review.py プロジェクト: mwiencek/critiquebrainz
def hide(id):
    review = Review.query.get_or_404(str(id))

    if review.is_hidden:
        flash.info(gettext("Review is already hidden."))
        return redirect(url_for('.entity', id=review.id))

    form = AdminActionForm()
    if form.validate_on_submit():
        review.hide()
        ModerationLog.create(admin_id=current_user.id,
                             action=ACTION_HIDE_REVIEW,
                             reason=form.reason.data,
                             review_id=review.id)
        for report in db_spam_report.list_reports(review_id=review.id):
            db_spam_report.archive(report["user_id"], report["revision_id"])
        flash.success(gettext("Review has been hidden."))
        return redirect(url_for('.entity', id=review.id))

    return render_template('log/action.html',
                           review=review,
                           form=form,
                           action=ACTION_HIDE_REVIEW)
コード例 #7
0
 def test_list_reports(self):
     db_spam_report.create(self.revision_id, self.user2.id, "This is a report")
     db_review.update(
         review_id=self.review["id"],
         drafted=self.review["is_draft"],
         text="Updated Review",
     )
     self.review = db_review.get_by_id(self.review["id"])
     db_spam_report.create(self.review["last_revision"]["id"], self.user1.id, "This is again a report on the updated review")
     # two reports on the old revision and one on the new revision.
     reports, count = db_spam_report.list_reports(review_id=self.review["id"])  # pylint: disable=unused-variable
     self.assertEqual(count, 3)
     # get all reports by a user.
     reports, count = db_spam_report.list_reports(user_id=self.user2.id)
     self.assertEqual(count, 1)
     # archive and include all archived reports.
     # there must be two reports including the archived one.
     db_spam_report.archive(self.user1.id, self.review["last_revision"]["id"])
     reports, count = db_spam_report.list_reports(inc_archived=True)
     self.assertEqual(count, 3)
     # there must be one reports excluding the archived one.
     reports, count = db_spam_report.list_reports(inc_archived=False)
     self.assertEqual(count, 2)
コード例 #8
0
 def test_archive(self):
     db_spam_report.archive(self.user1.id, self.revision_id)
     report = db_spam_report.get(self.user1.id, self.revision_id)
     self.assertEqual(report['is_archived'], True)
コード例 #9
0
 def test_archive(self):
     db_spam_report.archive(self.user1.id, self.revision_id)
     report = db_spam_report.get(self.user1.id, self.revision_id)
     self.assertEqual(report['is_archived'], True)