diff --git a/webapp/titanembeds/blueprints/admin/admin.py b/webapp/titanembeds/blueprints/admin/admin.py index dafb2a4..3e20eac 100644 --- a/webapp/titanembeds/blueprints/admin/admin.py +++ b/webapp/titanembeds/blueprints/admin/admin.py @@ -1,6 +1,7 @@ from flask import Blueprint, url_for, redirect, session, render_template, abort, request from functools import wraps -from titanembeds.database import db, get_administrators_list, Cosmetics +from titanembeds.database import db, get_administrators_list, Cosmetics, Guilds +from titanembeds.oauth import generate_guild_icon_url admin = Blueprint("admin", __name__) @@ -73,4 +74,59 @@ def cosmetics_patch(): entry.css = css db.session.commit() return ('', 204) - \ No newline at end of file + +@admin.route("/administrate_guild/", methods=["GET"]) +@is_admin +def administrate_guild(guild_id): + db_guild = db.session.query(Guilds).filter(Guilds.guild_id == guild_id).first() + session["redirect"] = None + permissions=[] + permissions.append("Manage Embed Settings") + permissions.append("Ban Members") + permissions.append("Kick Members") + 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) + dbguild_dict = { + "id": db_guild.guild_id, + "name": db_guild.name, + "unauth_users": db_guild.unauth_users, + "visitor_view": db_guild.visitor_view, + "chat_links": db_guild.chat_links, + "bracket_links": db_guild.bracket_links, + "mentions_limit": db_guild.mentions_limit, + "icon": db_guild.icon, + "discordio": db_guild.discordio if db_guild.discordio != None else "" + } + return render_template("administrate_guild.html.j2", guild=dbguild_dict, members=users, permissions=permissions) + +@admin.route("/administrate_guild/", methods=["POST"]) +@is_admin +def update_administrate_guild(guild_id): + db_guild = db.session.query(Guilds).filter(Guilds.guild_id == guild_id).first() + db_guild.unauth_users = request.form.get("unauth_users", db_guild.unauth_users) in ["true", True] + db_guild.visitor_view = request.form.get("visitor_view", db_guild.visitor_view) in ["true", True] + db_guild.chat_links = request.form.get("chat_links", db_guild.chat_links) in ["true", True] + db_guild.bracket_links = request.form.get("bracket_links", db_guild.bracket_links) in ["true", True] + db_guild.mentions_limit = request.form.get("mentions_limit", db_guild.mentions_limit) + + discordio = request.form.get("discordio", db_guild.discordio) + if discordio and discordio.strip() == "": + discordio = None + db_guild.discordio = discordio + db.session.commit() + return jsonify( + id=db_guild.id, + guild_id=db_guild.guild_id, + unauth_users=db_guild.unauth_users, + chat_links=db_guild.chat_links, + bracket_links=db_guild.bracket_links, + mentions_limit=db_guild.mentions_limit, + discordio=db_guild.discordio, + ) + +@user.route("/guilds") +@is_admin +def guilds(): + guilds = db.session.query(Guilds).all() + return render_template("admin_guilds.html.j2", servers=guilds, icon_generate=generate_guild_icon_url) diff --git a/webapp/titanembeds/templates/admin_guilds.html.j2 b/webapp/titanembeds/templates/admin_guilds.html.j2 new file mode 100644 index 0000000..1a68e62 --- /dev/null +++ b/webapp/titanembeds/templates/admin_guilds.html.j2 @@ -0,0 +1,32 @@ +{% extends 'site_layout.html.j2' %} +{% set title="Admin" %} + +{% block content %} +

Manage Guilds (Admin)

+

Select a server to configure Titan Embeds.

+
+ {% for server in servers %} +
+
+
+
+ {% if server.icon %} + + {% else %} + No icon :( + {% endif %} +
+
+ +

{{ server.name }}

+
+ Modify +
+
+
+
+
+ {% endfor %} +
+ +{% endblock %} diff --git a/webapp/titanembeds/templates/admin_index.html.j2 b/webapp/titanembeds/templates/admin_index.html.j2 index 6f9d5ec..ad74096 100644 --- a/webapp/titanembeds/templates/admin_index.html.j2 +++ b/webapp/titanembeds/templates/admin_index.html.j2 @@ -13,5 +13,12 @@ Manage +
+
+

Guilds

+

Manage any guild in Titan, this will give you the normal dashboard.

+ Manage +
+
{% endblock %}