diff --git a/discordbot/titanembeds/database/guilds.py b/discordbot/titanembeds/database/guilds.py index ee647cf..a73ccb0 100644 --- a/discordbot/titanembeds/database/guilds.py +++ b/discordbot/titanembeds/database/guilds.py @@ -14,6 +14,7 @@ class Guilds(Base): emojis = db.Column(db.Text()) # Guild Emojis owner_id = db.Column(db.String(255)) # Snowflake of the owner icon = db.Column(db.String(255)) # The icon string, null if none + discordio = db.Column(db.String(255)) # Custom Discord.io Invite Link def __init__(self, guild_id, name, roles, channels, emojis, owner_id, icon): self.guild_id = guild_id diff --git a/webapp/alembic/versions/95ab6a63135d_modified_guilds_table_for_discordio_.py b/webapp/alembic/versions/95ab6a63135d_modified_guilds_table_for_discordio_.py new file mode 100644 index 0000000..cbe3982 --- /dev/null +++ b/webapp/alembic/versions/95ab6a63135d_modified_guilds_table_for_discordio_.py @@ -0,0 +1,28 @@ +"""Modified guilds table for discordio capability + +Revision ID: 95ab6a63135d +Revises: 32a4d2d7b85f +Create Date: 2017-06-04 05:06:13.118878 + +""" + +# revision identifiers, used by Alembic. +revision = '95ab6a63135d' +down_revision = '32a4d2d7b85f' +branch_labels = None +depends_on = None + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('guilds', sa.Column('discordio', sa.String(length=255), nullable=True)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('guilds', 'discordio') + # ### end Alembic commands ### diff --git a/webapp/titanembeds/blueprints/user/user.py b/webapp/titanembeds/blueprints/user/user.py index 0b0b32c..558a3bb 100644 --- a/webapp/titanembeds/blueprints/user/user.py +++ b/webapp/titanembeds/blueprints/user/user.py @@ -178,7 +178,8 @@ def administrate_guild(guild_id): "chat_links": db_guild.chat_links, "bracket_links": db_guild.bracket_links, "mentions_limit": db_guild.mentions_limit, - "icon": db_guild.icon + "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) @@ -194,6 +195,11 @@ def update_administrate_guild(guild_id): 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.strip() == "": + discordio = None + db_guild.discordio = discordio db.session.commit() return jsonify( id=db_guild.id, @@ -202,6 +208,7 @@ def update_administrate_guild(guild_id): chat_links=db_guild.chat_links, bracket_links=db_guild.bracket_links, mentions_limit=db_guild.mentions_limit, + discordio=db_guild.discordio, ) @user.route("/add-bot/") diff --git a/webapp/titanembeds/database/guilds.py b/webapp/titanembeds/database/guilds.py index cba6f4b..934bf6a 100644 --- a/webapp/titanembeds/database/guilds.py +++ b/webapp/titanembeds/database/guilds.py @@ -14,6 +14,7 @@ class Guilds(db.Model): emojis = db.Column(db.Text(), nullable=False) # Guild Emojis owner_id = db.Column(db.String(255), nullable=False) # Snowflake of the owner icon = db.Column(db.String(255)) # The icon string, null if none + discordio = db.Column(db.String(255)) # Custom Discord.io Invite Link def __init__(self, guild_id, name, roles, channels, emojis, owner_id, icon): self.guild_id = guild_id diff --git a/webapp/titanembeds/static/js/administrate_guild.js b/webapp/titanembeds/static/js/administrate_guild.js index b4c6a75..d689ceb 100644 --- a/webapp/titanembeds/static/js/administrate_guild.js +++ b/webapp/titanembeds/static/js/administrate_guild.js @@ -36,6 +36,17 @@ $("#mentions_limit").keyup(function(event){ } }); +$("#discordio").keyup(function(event){ + if(event.keyCode == 13){ + var pathname = window.location.pathname; + var value = $("#discordio").val() + var payload = {"discordio": value} + $.post(pathname, payload, function(data) { + Materialize.toast('Updated Discord.io setting!', 2000) + }); + } +}); + function initiate_ban(guild_id, user_id) { var reason = prompt("Please enter your reason for ban"); var payload = { diff --git a/webapp/titanembeds/templates/administrate_guild.html.j2 b/webapp/titanembeds/templates/administrate_guild.html.j2 index e429f30..438a08d 100644 --- a/webapp/titanembeds/templates/administrate_guild.html.j2 +++ b/webapp/titanembeds/templates/administrate_guild.html.j2 @@ -79,6 +79,13 @@

Message mentions limit

(-1 to have no limit - enter to submit)

+ +
+ +

Custom Discord.io Link

+

Because we are a partner with Discord.io, we enable you to enter your custom discord.io link and replace the discord.gg link on the embed!

+

(Leave blank if none - enter to submit)

+