From 3e884fa2fa5c2c40a03c2cc554626bff457ac112 Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Sat, 25 Mar 2017 21:14:42 -0700 Subject: [PATCH] Fix a few stuff in dashboard --- titanembeds/app.py | 4 +++- titanembeds/blueprints/embed/__init__.py | 1 + titanembeds/blueprints/embed/embed.py | 7 +++++++ titanembeds/blueprints/user/user.py | 6 ++++-- titanembeds/templates/administrate_guild.html.j2 | 5 +++-- 5 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 titanembeds/blueprints/embed/__init__.py diff --git a/titanembeds/app.py b/titanembeds/app.py index 86aff33..5be6132 100644 --- a/titanembeds/app.py +++ b/titanembeds/app.py @@ -4,6 +4,7 @@ from flask import Flask, render_template, request, session, url_for, redirect, j from titanembeds.utils import cache import blueprints.api import blueprints.user +import blueprints.embed import os @@ -18,6 +19,7 @@ cache.init_app(app, config={'CACHE_TYPE': 'simple'}) app.register_blueprint(blueprints.api.api, url_prefix="/api", template_folder="/templates") app.register_blueprint(blueprints.user.user, url_prefix="/user", template_folder="/templates") +app.register_blueprint(blueprints.embed.embed, url_prefix="/embed", template_folder="/templates") @app.route("/set_username//", methods=["GET"]) def get_set_username(guildid, channelid): @@ -32,7 +34,7 @@ def post_set_username(guildid, channelid): def index(): return render_template("index.html.j2") -@app.route("/embed//") +@app.route("/oldembed//") def embed_get(guildid, channelid): if 'username' not in session: return redirect(url_for("get_set_username", guildid=guildid, channelid=channelid)) diff --git a/titanembeds/blueprints/embed/__init__.py b/titanembeds/blueprints/embed/__init__.py new file mode 100644 index 0000000..34cd6de --- /dev/null +++ b/titanembeds/blueprints/embed/__init__.py @@ -0,0 +1 @@ +from embed import embed diff --git a/titanembeds/blueprints/embed/embed.py b/titanembeds/blueprints/embed/embed.py index e69de29..2c1d31a 100644 --- a/titanembeds/blueprints/embed/embed.py +++ b/titanembeds/blueprints/embed/embed.py @@ -0,0 +1,7 @@ +from flask import Blueprint + +embed = Blueprint("embed", __name__) + +@embed.route("/") +def guild_embed(guild_id): + return guild_id diff --git a/titanembeds/blueprints/user/user.py b/titanembeds/blueprints/user/user.py index 1617965..b0103c0 100644 --- a/titanembeds/blueprints/user/user.py +++ b/titanembeds/blueprints/user/user.py @@ -162,7 +162,7 @@ def administrate_guild(guild_id): guild = discord_api.get_guild(guild_id) if guild['code'] != 200: return redirect(generate_bot_invite_url(guild_id)) - db_guild = Guilds.query.filter_by(guild_id=guild_id).first() + db_guild = db.session.query(Guilds).filter(Guilds.guild_id == guild_id).first() if not db_guild: db_guild = Guilds(guild_id) db.session.add(db_guild) @@ -177,7 +177,9 @@ def administrate_guild(guild_id): all_members = db.session.query(UnauthenticatedUsers).filter(UnauthenticatedUsers.guild_id == guild_id).all() all_bans = db.session.query(UnauthenticatedBans).filter(UnauthenticatedBans.guild_id == guild_id).all() users = prepare_guild_members_list(all_members, all_bans) - return render_template("administrate_guild.html.j2", guild=guild['content'], members=users, permissions=permissions) + 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) @user.route('/me') @discord_users_only() diff --git a/titanembeds/templates/administrate_guild.html.j2 b/titanembeds/templates/administrate_guild.html.j2 index be15ddc..24778f1 100644 --- a/titanembeds/templates/administrate_guild.html.j2 +++ b/titanembeds/templates/administrate_guild.html.j2 @@ -20,8 +20,9 @@

Direct Link

- +

iFrame Embed

+
@@ -38,7 +39,7 @@