def ban_comment(comment_id): form = BanForm() if form.validate_on_submit(): reports = Report.query.filter_by(comment_id=comment_id).all() comment = Comment.query.filter_by(id=comment_id).first_or_404() comment.banned = 1 comment.ban_reason = form.reason.data comment.author.demerits += 1 for report in reports: db.session.delete(report) db.session.commit() flash("Case resolved") return redirect(request.referrer)
def ban_profile(profile_id): form = BanForm() if form.validate_on_submit(): reports = Report.query.filter_by(profile_id=profile_id).all() profile = User.query.filter_by(id=profile_id).first_or_404() profile.banned = 1 profile.ban_reason = form.reason.data for report in reports: db.session.delete(report) db.session.commit() flash("Case resolved") return redirect(request.referrer) return redirect(url_for('index'))
def ban_post(post_id): form = BanForm() if form.validate_on_submit(): reports = Report.query.filter_by(post_id=post_id).all() post = Post.query.filter_by(id=post_id).first_or_404() post.banned = 1 post.ban_reason = form.reason.data post.author.upvotes -= post.votes post.author.demerits += 1 assign_badge(post.author) for report in reports: db.session.delete(report) db.session.commit() flash("Case resolved") return redirect(request.referrer)