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)
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)