ping group fixes

master
Aevann 2023-12-06 22:54:42 +02:00
parent ffe728946c
commit b38f918af6
2 changed files with 11 additions and 5 deletions

View File

@ -187,8 +187,12 @@ def group_reject(v, group_name, user_id):
if not membership:
abort(404, "There is no membership to reject!")
if v.id != group.owner.id and membership.is_mod:
abort(403, "Only the group owner can kick mods!")
if v.id != membership.user_id: #implies kicking and not leaving
if membership.user_id == group.owner.id:
abort(403, "You can't kick the group owner!")
if v.id != group.owner.id and membership.is_mod:
abort(403, "Only the group owner can kick mods!")
if v.id == membership.user_id:
msg = f"You have left !{group} successfully!"

View File

@ -66,9 +66,11 @@
</div>
{% endif %}
<div id="kick-{{membership.user_id}}" {% if name == 'applications' %}class="d-none"{% endif %}>
<button type="button" class="btn btn-danger btn-block" data-nonce="{{g.nonce}}" data-onclick="reject_membership(this,'{{group}}','{{membership.user_id}}')">{% if v.id == membership.user_id %}Leave{% else %}Kick{% endif %}</button>
</div>
{% if v.id == membership.user_id or v.id == group.owner.id or not membership.user.mods_group(group) %}
<div id="kick-{{membership.user_id}}" {% if name == 'applications' %}class="d-none"{% endif %}>
<button type="button" class="btn btn-danger btn-block" data-nonce="{{g.nonce}}" data-onclick="reject_membership(this,'{{group}}','{{membership.user_id}}')">{% if v.id == membership.user_id %}Leave{% else %}Kick{% endif %}</button>
</div>
{% endif %}
<div {% if name == 'members' %}class="d-none"{% endif %}>
<button type="button" class="btn btn-success btn-block" data-nonce="{{g.nonce}}" data-onclick="approve_membership(this,'{{group}}','{{membership.user_id}}')">Approve</button>