diff --git a/files/assets/js/group_members_owner.js b/files/assets/js/group_members_owner.js index 4e8ccdc39..6c8035150 100644 --- a/files/assets/js/group_members_owner.js +++ b/files/assets/js/group_members_owner.js @@ -1,4 +1,5 @@ const members_tbody = document.getElementById('members_tbody') +const myself_in_table = document.getElementById('myself-in-table') function approve_membership(t, group, uid) { url = `/!${group}/${uid}/approve` @@ -12,6 +13,10 @@ function approve_membership(t, group, uid) { document.getElementById(`time-${uid}`).innerHTML = formatTime(new Date()); 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)); t.parentElement.remove() } diff --git a/files/classes/group_membership.py b/files/classes/group_membership.py index e0adf493d..964505ba1 100644 --- a/files/classes/group_membership.py +++ b/files/classes/group_membership.py @@ -13,8 +13,10 @@ class GroupMembership(Base): created_utc = Column(Integer) approved_utc = Column(Integer) 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): if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time()) diff --git a/files/routes/groups.py b/files/routes/groups.py index 35260ff18..a0ba3411a 100644 --- a/files/routes/groups.py +++ b/files/routes/groups.py @@ -189,6 +189,7 @@ def group_approve(v, group_name, user_id): if not application.approved_utc: application.approved_utc = time.time() + application.approver_id = v.id g.db.add(application) if v.id != application.user_id: send_repeatable_notification(application.user_id, f"@{v.username} has approved your application to !{group}") diff --git a/files/templates/group_memberships.html b/files/templates/group_memberships.html index b6e628685..519c9b877 100644 --- a/files/templates/group_memberships.html +++ b/files/templates/group_memberships.html @@ -1,6 +1,14 @@ {% extends "default.html" %} {% block pagetitle %}!{{group}}{% endblock %} {% block content %} + {% if v.mods_group(group) %} +