コード例 #1
0
    def test_log_deletion(self):
        log = ModerationLog.create(admin_id=self.admin.id, reason=self.reason,
                                   action=ACTION_HIDE_REVIEW, review_id=self.review.id)
        self.assertEqual(ModerationLog.query.count(), 1)

        log.delete()
        self.assertEqual(ModerationLog.query.count(), 0)
コード例 #2
0
ファイル: views.py プロジェクト: ortizginer/critiquebrainz
def block(user_id):
    user = User.query.get_or_404(str(user_id))

    if user.is_blocked:
        flash(gettext("This account is already blocked."), 'info')
        return redirect(url_for('user.reviews', user_id=user.id))

    form = AdminActionForm()
    if form.validate_on_submit():
        user.block()
        ModerationLog.create(admin_id=current_user.id, action=ACTION_BLOCK_USER,
                             reason=form.reason.data, user_id=user.id)
        flash(gettext("This user account has been blocked."), 'success')
        return redirect(url_for('user.reviews', user_id=user.id))

    return render_template('log/action.html', user=user, form=form, action=ACTION_BLOCK_USER)
コード例 #3
0
    def test_log_deletion(self):
        log = ModerationLog.create(admin_id=self.admin.id, reason=self.reason,
                                   action=ACTION_HIDE_REVIEW, review_id=self.review.id)
        self.assertEqual(ModerationLog.query.count(), 1)

        log.delete()
        self.assertEqual(ModerationLog.query.count(), 0)
コード例 #4
0
ファイル: log.py プロジェクト: adeshp96/critiquebrainz
def more():
    page = int(request.args.get('page', default=0))
    offset = page * RESULTS_LIMIT

    results, count = ModerationLog.list(offset=offset, limit=RESULTS_LIMIT)
    results = groupby(results, lambda log: log.timestamp.strftime('%d %b, %G'))

    template = render_template('log/log_results.html', results=results)
    return jsonify(results=template, more=(count-offset-RESULTS_LIMIT) > 0)
コード例 #5
0
ファイル: log.py プロジェクト: adeshp96/critiquebrainz
def browse():
    results, count = ModerationLog.list(limit=RESULTS_LIMIT)

    if not results:
        flash(gettext("No logs to display."), "warning")

    results = groupby(results, lambda log: log.timestamp.strftime('%d %b, %G'))

    return render_template('log/browse.html', count=count, results=results, limit=RESULTS_LIMIT)
コード例 #6
0
ファイル: review.py プロジェクト: dpmittal/critiquebrainz
def hide(id):
    review = Review.query.get_or_404(str(id))

    if review.is_hidden:
        flash(gettext("Review is already hidden."), 'info')
        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 SpamReport.list(review_id=review.id)[0]:
            report.archive()
        flash(gettext("Review has been hidden."), 'success')
        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 hide(id):
    review = Review.query.get_or_404(str(id))

    if review.is_hidden:
        flash(gettext("Review is already hidden."), 'info')
        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 SpamReport.list(review_id=review.id)[0]:
            report.archive()
        flash(gettext("Review has been hidden."), 'success')
        return redirect(url_for('.entity', id=review.id))

    return render_template('log/action.html', review=review, form=form, action=ACTION_HIDE_REVIEW)
コード例 #8
0
def more():
    page = int(request.args.get('page', default=0))
    offset = page * RESULTS_LIMIT

    results, count = ModerationLog.list(offset=offset, limit=RESULTS_LIMIT)
    results = groupby(results, lambda log: log.timestamp.strftime('%d %b, %G'))

    template = render_template('log/log_results.html', results=results)
    return jsonify(results=template, more=(count - offset - RESULTS_LIMIT) > 0)
コード例 #9
0
    def test_log_creation(self):
        self.assertEqual(ModerationLog.query.count(), 0)

        log = ModerationLog.create(admin_id=self.admin.id, reason=self.reason,
                                   action=ACTION_BLOCK_USER, user_id=self.user.id)

        all_logs = ModerationLog.query.all()
        self.assertEqual(len(all_logs), 1)
        self.assertEqual(all_logs[0].user_id, log.user_id)
        self.assertEqual(all_logs[0].reason, log.reason)
コード例 #10
0
    def test_log_creation(self):
        self.assertEqual(ModerationLog.query.count(), 0)

        log = ModerationLog.create(admin_id=self.admin.id, reason=self.reason,
                                   action=ACTION_BLOCK_USER, user_id=self.user.id)

        all_logs = ModerationLog.query.all()
        self.assertEqual(len(all_logs), 1)
        self.assertEqual(all_logs[0].user_id, log.user_id)
        self.assertEqual(all_logs[0].reason, log.reason)
コード例 #11
0
def browse():
    results, count = ModerationLog.list(limit=RESULTS_LIMIT)

    if not results:
        flash(gettext("No logs to display."), "warning")

    results = groupby(results, lambda log: log.timestamp.strftime('%d %b, %G'))

    return render_template('log/browse.html',
                           count=count,
                           results=results,
                           limit=RESULTS_LIMIT)
コード例 #12
0
ファイル: user.py プロジェクト: mwiencek/critiquebrainz
def block(user_id):
    user = db_users.get_by_id(user_id)
    if not user:
        abort(404)

    if user['is_blocked']:
        flash.info(gettext("This account is already blocked."))
        return redirect(url_for('user.reviews', user_id=user['id']))

    form = AdminActionForm()
    if form.validate_on_submit():
        db_users.block(user['id'])
        ModerationLog.create(admin_id=current_user.id,
                             action=ACTION_BLOCK_USER,
                             reason=form.reason.data,
                             user_id=user['id'])
        flash.success(gettext("This user account has been blocked."))
        return redirect(url_for('user.reviews', user_id=user['id']))

    return render_template('log/action.html',
                           user=user,
                           form=form,
                           action=ACTION_BLOCK_USER)