forked from MarseyWorld/MarseyWorld
add "approved by" to ping groups
parent
b3d5d49c1f
commit
d2e22c8a35
|
@ -1,4 +1,5 @@
|
||||||
const members_tbody = document.getElementById('members_tbody')
|
const members_tbody = document.getElementById('members_tbody')
|
||||||
|
const myself_in_table = document.getElementById('myself-in-table')
|
||||||
|
|
||||||
function approve_membership(t, group, uid) {
|
function approve_membership(t, group, uid) {
|
||||||
url = `/!${group}/${uid}/approve`
|
url = `/!${group}/${uid}/approve`
|
||||||
|
@ -12,6 +13,10 @@ function approve_membership(t, group, uid) {
|
||||||
document.getElementById(`time-${uid}`).innerHTML = formatTime(new Date());
|
document.getElementById(`time-${uid}`).innerHTML = formatTime(new Date());
|
||||||
document.getElementById(`counter-${uid}`).innerHTML = parseInt(members_tbody.lastElementChild.firstElementChild.innerHTML) + 1
|
document.getElementById(`counter-${uid}`).innerHTML = parseInt(members_tbody.lastElementChild.firstElementChild.innerHTML) + 1
|
||||||
|
|
||||||
|
const myself_in_table_cloned = document.createElement('td')
|
||||||
|
myself_in_table_cloned.innerHTML = myself_in_table.innerHTML
|
||||||
|
document.getElementById(uid).append(myself_in_table_cloned)
|
||||||
|
|
||||||
members_tbody.append(document.getElementById(uid));
|
members_tbody.append(document.getElementById(uid));
|
||||||
t.parentElement.remove()
|
t.parentElement.remove()
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,10 @@ class GroupMembership(Base):
|
||||||
created_utc = Column(Integer)
|
created_utc = Column(Integer)
|
||||||
approved_utc = Column(Integer)
|
approved_utc = Column(Integer)
|
||||||
is_mod = Column(Boolean, default=False)
|
is_mod = Column(Boolean, default=False)
|
||||||
|
approver_id = Column(Integer, ForeignKey("users.id"))
|
||||||
|
|
||||||
user = relationship("User", uselist=False)
|
user = relationship("User", primaryjoin="User.id==GroupMembership.user_id", uselist=False)
|
||||||
|
approver = relationship("User", primaryjoin="User.id==GroupMembership.approver_id", uselist=False)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
||||||
|
|
|
@ -189,6 +189,7 @@ def group_approve(v, group_name, user_id):
|
||||||
|
|
||||||
if not application.approved_utc:
|
if not application.approved_utc:
|
||||||
application.approved_utc = time.time()
|
application.approved_utc = time.time()
|
||||||
|
application.approver_id = v.id
|
||||||
g.db.add(application)
|
g.db.add(application)
|
||||||
if v.id != application.user_id:
|
if v.id != application.user_id:
|
||||||
send_repeatable_notification(application.user_id, f"@{v.username} has approved your application to !{group}")
|
send_repeatable_notification(application.user_id, f"@{v.username} has approved your application to !{group}")
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
{% extends "default.html" %}
|
{% extends "default.html" %}
|
||||||
{% block pagetitle %}!{{group}}{% endblock %}
|
{% block pagetitle %}!{{group}}{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
{% if v.mods_group(group) %}
|
||||||
|
<div id="myself-in-table" class="d-none">
|
||||||
|
{% with user=v %}
|
||||||
|
{% include "user_in_table.html" %}
|
||||||
|
{% endwith %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<div class="mx-2">
|
<div class="mx-2">
|
||||||
{% if v.id != group.owner_id %}
|
{% 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')">
|
<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')">
|
||||||
|
@ -56,6 +64,7 @@
|
||||||
|
|
||||||
{% if name == 'members' %}
|
{% if name == 'members' %}
|
||||||
<th>Approved on</th>
|
<th>Approved on</th>
|
||||||
|
<th>Approved by</th>
|
||||||
{% else %}
|
{% else %}
|
||||||
<th>Applied on</th>
|
<th>Applied on</th>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -105,6 +114,11 @@
|
||||||
|
|
||||||
{% if name == 'members' %}
|
{% if name == 'members' %}
|
||||||
<td id="time-{{membership.user_id}}" data-time="{{membership.approved_utc}}"></td>
|
<td id="time-{{membership.user_id}}" data-time="{{membership.approved_utc}}"></td>
|
||||||
|
<td>
|
||||||
|
{% with user=membership.approver %}
|
||||||
|
{% include "user_in_table.html" %}
|
||||||
|
{% endwith %}
|
||||||
|
</td>
|
||||||
{% else %}
|
{% else %}
|
||||||
<td id="time-{{membership.user_id}}" data-time="{{membership.created_utc}}"></td>
|
<td id="time-{{membership.user_id}}" data-time="{{membership.created_utc}}"></td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
alter table group_memberships add column approver_id int;
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.group_memberships
|
||||||
|
ADD CONSTRAINT group_memberships_approver_fkey FOREIGN KEY (approver_id) REFERENCES public.users(id);
|
Loading…
Reference in New Issue