diff --git a/titanembeds/blueprints/user/user.py b/titanembeds/blueprints/user/user.py index c04cbc4..f9a8d45 100644 --- a/titanembeds/blueprints/user/user.py +++ b/titanembeds/blueprints/user/user.py @@ -4,6 +4,8 @@ from titanembeds.decorators import discord_users_only from titanembeds.utils import discord_api from titanembeds.database import db, Guilds, UnauthenticatedUsers, UnauthenticatedBans from titanembeds.oauth import authorize_url, token_url, make_authenticated_session, get_current_authenticated_user, get_user_managed_servers, check_user_can_administrate_guild, check_user_permission, generate_avatar_url, generate_guild_icon_url, generate_bot_invite_url +import time +import datetime user = Blueprint("user", __name__) @@ -90,7 +92,6 @@ def administrate_guild(guild_id): all_members = db.session.query(UnauthenticatedUsers).filter(UnauthenticatedUsers.guild_id == guild_id).order_by(UnauthenticatedUsers.last_timestamp).all() all_bans = db.session.query(UnauthenticatedBans).filter(UnauthenticatedBans.guild_id == guild_id).all() users = prepare_guild_members_list(all_members, all_bans) - users.reverse() dbguild_dict = {"unauth_users": db_guild.unauth_users} return render_template("administrate_guild.html.j2", guild=guild['content'], dbguild=dbguild_dict, members=users, permissions=permissions) @@ -120,6 +121,8 @@ def me(): def prepare_guild_members_list(members, bans): all_users = [] + ip_pool = [] + members = sorted(members, key=lambda k: datetime.datetime.strptime(str(k.last_timestamp), "%Y-%m-%d %H:%M:%S"), reverse=True) for member in members: user = { "id": member.id, @@ -133,6 +136,7 @@ def prepare_guild_members_list(members, bans): "banned_by": None, "banned_reason": None, "ban_lifted_by": None, + "aliases": [], } for banned in bans: if banned.ip_address == member.ip_address: @@ -143,7 +147,16 @@ def prepare_guild_members_list(members, bans): user['banned_reason'] = banned.reason user['ban_lifted_by'] = banned.lifter_id continue - all_users.append(user) + if user["ip"] not in ip_pool: + all_users.append(user) + ip_pool.append(user["ip"]) + else: + for usr in all_users: + if user["ip"] == usr["ip"]: + alias = user["username"]+"#"+str(user["discrim"]) + if len(usr["aliases"]) < 5 and alias not in usr["aliases"]: + usr["aliases"].append(alias) + continue return all_users @user.route("/ban", methods=["POST"]) diff --git a/titanembeds/static/css/administrate_guild.css b/titanembeds/static/css/administrate_guild.css new file mode 100644 index 0000000..d412512 --- /dev/null +++ b/titanembeds/static/css/administrate_guild.css @@ -0,0 +1,77 @@ +/* Responsive table CSS, directly from materializecss - slightly modified */ +/* Used to accomplish having permanent horizontal table */ + +table.responsive-table { + width: 100%; + border-collapse: collapse; + border-spacing: 0; + display: block; + position: relative; + table-layout: fixed; + /* sort out borders */ +} +table.responsive-table td:empty:before { + content: '\00a0'; +} +table.responsive-table th, +table.responsive-table td { + margin: 0; + vertical-align: top; +} +table.responsive-table th { + text-align: left; +} +table.responsive-table thead { + display: block; + float: left; +} +table.responsive-table thead tr { + display: block; + padding: 0 10px 0 0; +} +table.responsive-table thead tr th::before { + content: "\00a0"; +} +table.responsive-table tbody { + display: block; + width: auto; + position: relative; + overflow-x: auto; + white-space: nowrap; +} +table.responsive-table tbody tr { + display: inline-block; + vertical-align: top; +} +table.responsive-table th { + display: block; + text-align: right; +} +table.responsive-table td { + display: block; + min-height: 1.25em; + text-align: left; + padding: 13px 5px; +} +table.responsive-table tr { + padding: 0 10px; +} +table.responsive-table thead { + border: 0; + border-right: 1px solid #d0d0d0; +} +table.responsive-table.bordered th { + border-bottom: 0; + border-left: 0; +} +table.responsive-table.bordered td { + border-left: 0; + border-right: 0; + border-bottom: 0; +} +table.responsive-table.bordered tr { + border: 0; +} +table.responsive-table.bordered tbody tr { + border-right: 1px solid #d0d0d0; +} diff --git a/titanembeds/static/css/style.css b/titanembeds/static/css/style.css index acf12b1..102f493 100644 --- a/titanembeds/static/css/style.css +++ b/titanembeds/static/css/style.css @@ -57,4 +57,4 @@ nav { border-radius: 50px; border: 2px solid #37474f; color: #eceff1; -} \ No newline at end of file +} diff --git a/titanembeds/templates/administrate_guild.html.j2 b/titanembeds/templates/administrate_guild.html.j2 index 84ed3d2..49331ea 100644 --- a/titanembeds/templates/administrate_guild.html.j2 +++ b/titanembeds/templates/administrate_guild.html.j2 @@ -1,6 +1,10 @@ {% extends 'site_layout.html.j2' %} {% block title %}Administrate Guild: {{ guild['name'] }}{% endblock %} +{% block additional_head_elements %} + +{% endblock %} + {% block content %}
For this server, you are allowed the following actions: @@ -72,6 +76,7 @@
Note that all bans are by IP. Seeing duplicates? It is because users are generated a unique session on each browser load.
+Note that all bans are by IP. Seeing duplicates? It is because users are generated a unique session on each browser load. (Though we try to remove/concat any duplicates IP hashes)
diff --git a/titanembeds/templates/site_layout.html.j2 b/titanembeds/templates/site_layout.html.j2 index 3736b1f..ea4297f 100644 --- a/titanembeds/templates/site_layout.html.j2 +++ b/titanembeds/templates/site_layout.html.j2 @@ -11,7 +11,9 @@