mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
ban posts or comments - ui
This commit is contained in:
parent
654829cbae
commit
04cce6ec9d
7 changed files with 16 additions and 3 deletions
|
@ -208,6 +208,8 @@ class EditUserForm(FlaskForm):
|
|||
bot = BooleanField(_l('This profile is a bot'))
|
||||
verified = BooleanField(_l('Email address is verified'))
|
||||
banned = BooleanField(_l('Banned'))
|
||||
ban_posts = BooleanField(_l('Ban posts'))
|
||||
ban_comments = BooleanField(_l('Ban comments'))
|
||||
hide_type_choices = [(0, _l('Show')),
|
||||
(1, _l('Hide completely')),
|
||||
(2, _l('Blur')),
|
||||
|
|
|
@ -1097,6 +1097,8 @@ def admin_user_edit(user_id):
|
|||
if form.validate_on_submit():
|
||||
user.bot = form.bot.data
|
||||
user.banned = form.banned.data
|
||||
user.ban_posts = form.ban_posts.data
|
||||
user.ban_comments = form.ban_comments.data
|
||||
user.hide_nsfw = form.hide_nsfw.data
|
||||
user.hide_nsfl = form.hide_nsfl.data
|
||||
if form.verified.data and not user.verified:
|
||||
|
@ -1130,6 +1132,8 @@ def admin_user_edit(user_id):
|
|||
form.bot.data = user.bot
|
||||
form.verified.data = user.verified
|
||||
form.banned.data = user.banned
|
||||
form.ban_posts.data = user.ban_posts
|
||||
form.ban_comments.data = user.ban_comments
|
||||
form.hide_nsfw.data = user.hide_nsfw
|
||||
form.hide_nsfl.data = user.hide_nsfl
|
||||
if user.roles and user.roles.count() > 0:
|
||||
|
|
|
@ -587,7 +587,7 @@ def join_then_add(actor):
|
|||
@login_required
|
||||
@validation_required
|
||||
def add_post(actor, type):
|
||||
if current_user.banned:
|
||||
if current_user.banned or current_user.ban_posts:
|
||||
return show_ban_message()
|
||||
community = actor_to_community(actor)
|
||||
|
||||
|
|
|
@ -1668,6 +1668,9 @@ class PostReply(db.Model):
|
|||
if not post.comments_enabled:
|
||||
raise Exception('Comments are disabled on this post')
|
||||
|
||||
if user.ban_comments:
|
||||
raise Exception('Banned from commenting')
|
||||
|
||||
if in_reply_to is not None:
|
||||
parent_id = in_reply_to.id
|
||||
depth = in_reply_to.depth + 1
|
||||
|
|
|
@ -501,7 +501,7 @@ def continue_discussion(post_id, comment_id):
|
|||
@bp.route('/post/<int:post_id>/comment/<int:comment_id>/reply', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def add_reply(post_id: int, comment_id: int):
|
||||
if current_user.banned:
|
||||
if current_user.banned or current_user.ban_comments:
|
||||
return show_ban_message()
|
||||
post = Post.query.get_or_404(post_id)
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
{{ render_field(form.bot) }}
|
||||
{{ render_field(form.verified) }}
|
||||
{{ render_field(form.banned) }}
|
||||
{{ render_field(form.ban_posts) }}
|
||||
{{ render_field(form.ban_comments) }}
|
||||
<p>receive newsletter: {{ user.newsletter }}</p>
|
||||
{{ render_field(form.hide_nsfw) }}
|
||||
{{ render_field(form.hide_nsfl) }}
|
||||
|
|
|
@ -41,7 +41,9 @@
|
|||
</td>
|
||||
<td>{% if user.attitude != 1 %}{{ (user.attitude * 100) | round | int }}%{% endif %}</td>
|
||||
<td>{% if user.reputation %}R {{ user.reputation | round | int }}{% endif %}</td>
|
||||
<td>{{ '<span class="red">Banned</span>'|safe if user.banned }} </td>
|
||||
<td>{{ '<span class="red">Banned</span>'|safe if user.banned }}
|
||||
{{ '<span class="red">Banned posts</span>'|safe if user.ban_posts }}
|
||||
{{ '<span class="red">Banned comments</span>'|safe if user.ban_comments }}</td>
|
||||
<td>{{ user.reports if user.reports > 0 }} </td>
|
||||
<td>{{ user.ip_address if user.ip_address }}<br />{{ user.ip_address_country if user.ip_address_country }}</td>
|
||||
<td>{{ user.referrer if user.referrer }} </td>
|
||||
|
|
Loading…
Add table
Reference in a new issue