automatic acceptance for !focusgroup

pull/225/head
Aevann 2024-03-27 16:17:24 +02:00
parent a135abc6cf
commit 45472f5cc2
4 changed files with 9 additions and 9 deletions

View File

@ -186,7 +186,7 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, obj=None, followers_ping=Tr
continue
if i.group(1) == 'focusgroup' and not v.admin_level:
abort(403, f"Only admins can mention !focusgroup")
abort(403, "Only admins can mention !focusgroup")
if i.group(1) == 'everyone':
if charge:

View File

@ -74,17 +74,17 @@ def create_group(v):
def join_group(v, group_name):
group_name = group_name.strip().lower()
if group_name == 'verifiedrich':
if not v.patron:
abort(403, f"Only {patron}s can join !verifiedrich")
if group_name == 'verifiedrich' and not v.patron:
abort(403, f"Only {patron}s can join !verifiedrich")
if group_name in {'verifiedrich', 'focusgroup'}:
join = GroupMembership(
user_id=v.id,
group_name=group_name,
approved_utc = time.time()
)
g.db.add(join)
return {"message": "You have joined !verifiedrich successfully!"}
return {"message": f"You have joined !{group_name} successfully!"}
group = g.db.get(Group, group_name)
if not group: abort(404)

View File

@ -4,14 +4,14 @@
<div class="mx-2">
{% if v.id != group.owner_id %}
<button id="leave-{{group}}" type="button" class="mt-4 btn btn-danger btn-block {% if v.id not in group.membership_user_ids %}d-none{% endif %}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/!{{group}}/leave','leave-{{group}}','apply-{{group}}','d-none')">
{%- if v.id in group.member_ids or group.name == 'verifiedrich' -%}
{%- if v.id in group.member_ids or group.name in ('verifiedrich', 'focusgroup') -%}
Leave
{%- else -%}
Cancel Application
{%- endif -%}
</button>
<button id="apply-{{group}}" type="button" class="mt-4 {% if v.id in group.membership_user_ids %}d-none{% endif %} btn btn-success btn-block" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/!{{group}}/apply','leave-{{group}}','apply-{{group}}','d-none')">{% if group.name != 'verifiedrich' %}Apply to {% endif %}Join</button>
<button id="apply-{{group}}" type="button" class="mt-4 {% if v.id in group.membership_user_ids %}d-none{% endif %} btn btn-success btn-block" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/!{{group}}/apply','leave-{{group}}','apply-{{group}}','d-none')">{% if group.name not in ('verifiedrich', 'focusgroup') %}Apply to {% endif %}Join</button>
{% endif %}
{% if v.id == group.owner_id %}

View File

@ -51,14 +51,14 @@
<a href="/!{{group}}">{{group.member_ids | length}}</a>
{% if v.id != group.owner_id %}
<button id="leave-{{group}}" type="button" class="ml-3 ml-md-5 btn btn-primary {% if v.id not in group.membership_user_ids %}d-none{% endif %}" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/!{{group}}/leave','leave-{{group}}','apply-{{group}}','d-none')">
{%- if v.id in group.member_ids or group.name == 'verifiedrich' -%}
{%- if v.id in group.member_ids or group.name in ('verifiedrich', 'focusgroup') -%}
Leave
{%- else -%}
Cancel Application
{%- endif -%}
</button>
<button id="apply-{{group}}" type="button" class="ml-3 ml-md-5 {% if v.id in group.membership_user_ids %}d-none{% endif %} btn btn-primary" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/!{{group}}/apply','leave-{{group}}','apply-{{group}}','d-none')">{% if group.name != 'verifiedrich' %}Apply to {% endif %}Join</button>
<button id="apply-{{group}}" type="button" class="ml-3 ml-md-5 {% if v.id in group.membership_user_ids %}d-none{% endif %} btn btn-primary" data-nonce="{{g.nonce}}" data-onclick="postToastSwitch(this,'/!{{group}}/apply','leave-{{group}}','apply-{{group}}','d-none')">{% if group.name not in ('verifiedrich', 'focusgroup') %}Apply to {% endif %}Join</button>
{% endif %}
</td>
<td>