diff --git a/discordbot/titanembeds/database/guilds.py b/discordbot/titanembeds/database/guilds.py index 11abe96..ae819ca 100644 --- a/discordbot/titanembeds/database/guilds.py +++ b/discordbot/titanembeds/database/guilds.py @@ -8,7 +8,7 @@ class Guilds(Base): unauth_users = db.Column(db.Boolean()) # If allowed unauth users visitor_view = db.Column(db.Boolean()) # If users are automatically "signed in" and can view chat webhook_messages = db.Column(db.Boolean()) # Use webhooks to send messages instead of the bot - webhook_icon = db.Column(db.String(255), default=None) # Webhook icon url, None if unset + guest_icon = db.Column(db.String(255), default=None) # Guest icon url, None if unset chat_links = db.Column(db.Boolean()) # If users can post links bracket_links = db.Column(db.Boolean()) # If appending brackets to links to prevent embed mentions_limit = db.Column(db.Integer) # If there is a limit on the number of mentions in a msg @@ -26,7 +26,7 @@ class Guilds(Base): self.unauth_users = True # defaults to true self.visitor_view = False self.webhook_messages = False - self.webhook_icon = None + self.guest_icon = None self.chat_links = True self.bracket_links = True self.mentions_limit = -1 # -1 = unlimited mentions diff --git a/webapp/alembic/versions/109a6025e9ec_renamed_webhook_icon_to_guest_icon.py b/webapp/alembic/versions/109a6025e9ec_renamed_webhook_icon_to_guest_icon.py new file mode 100644 index 0000000..bb7d90e --- /dev/null +++ b/webapp/alembic/versions/109a6025e9ec_renamed_webhook_icon_to_guest_icon.py @@ -0,0 +1,30 @@ +"""Renamed webhook icon to guest icon + +Revision ID: 109a6025e9ec +Revises: 39815dfbcccb +Create Date: 2017-09-24 00:52:44.038589 + +""" + +# revision identifiers, used by Alembic. +revision = '109a6025e9ec' +down_revision = '39815dfbcccb' +branch_labels = None +depends_on = None + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('guilds', 'webhook_icon', new_column_name='guest_icon') + op.alter_column('cosmetics', 'webhook_icon', new_column_name='guest_icon') + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('guilds', 'guest_icon', new_column_name='webhook_icon') + op.alter_column('cosmetics', 'guest_icon', new_column_name='webhook_icon') + # ### end Alembic commands ### diff --git a/webapp/titanembeds/blueprints/admin/admin.py b/webapp/titanembeds/blueprints/admin/admin.py index 1b3c94b..2693d69 100644 --- a/webapp/titanembeds/blueprints/admin/admin.py +++ b/webapp/titanembeds/blueprints/admin/admin.py @@ -37,7 +37,7 @@ def cosmetics_post(): abort(400) css = request.form.get("css", None) css_limit = int(request.form.get("css_limit", 0)) - webhook_icon = request.form.get("webhook_icon", None) + guest_icon = request.form.get("guest_icon", None) entry = db.session.query(Cosmetics).filter(Cosmetics.user_id == user_id).first() if entry: abort(409) @@ -47,9 +47,9 @@ def cosmetics_post(): user.css = css if css_limit is not None: user.css_limit = css_limit - if webhook_icon is not None: - webhook_icon = webhook_icon.lower() == "true" - user.webhook_icon = webhook_icon + if guest_icon is not None: + guest_icon = guest_icon.lower() == "true" + user.guest_icon = guest_icon db.session.add(user) db.session.commit() return ('', 204) @@ -75,7 +75,7 @@ def cosmetics_patch(): abort(400) css = request.form.get("css", None) css_limit = request.form.get("css_limit", None) - webhook_icon = request.form.get("webhook_icon", None) + guest_icon = request.form.get("guest_icon", None) entry = db.session.query(Cosmetics).filter(Cosmetics.user_id == user_id).first() if not entry: abort(409) @@ -84,9 +84,9 @@ def cosmetics_patch(): entry.css = css if css_limit is not None: entry.css_limit = css_limit - if webhook_icon: - webhook_icon = webhook_icon.lower() == "true" - entry.webhook_icon = webhook_icon + if guest_icon: + guest_icon = guest_icon.lower() == "true" + entry.guest_icon = guest_icon db.session.commit() return ('', 204) def prepare_guild_members_list(members, bans): @@ -156,7 +156,7 @@ def administrate_guild(guild_id): "mentions_limit": db_guild.mentions_limit, "icon": db_guild.icon, "discordio": db_guild.discordio if db_guild.discordio != None else "", - "webhook_icon": db_guild.webhook_icon if db_guild.webhook_icon != None else "", + "guest_icon": db_guild.guest_icon if db_guild.guest_icon != None else "", } return render_template("administrate_guild.html.j2", guild=dbguild_dict, members=users, permissions=permissions, cosmetics=cosmetics) @@ -174,10 +174,10 @@ def update_administrate_guild(guild_id): if discordio != None and discordio.strip() == "": discordio = None db_guild.discordio = discordio - webhook_icon = request.form.get("webhook_icon", db_guild.webhook_icon) - if webhook_icon != None and webhook_icon.strip() == "": - webhook_icon = None - db_guild.webhook_icon = webhook_icon + guest_icon = request.form.get("guest_icon", db_guild.guest_icon) + if guest_icon != None and guest_icon.strip() == "": + guest_icon = None + db_guild.guest_icon = guest_icon db.session.commit() return jsonify( id=db_guild.id, @@ -189,7 +189,7 @@ def update_administrate_guild(guild_id): bracket_links=db_guild.bracket_links, mentions_limit=db_guild.mentions_limit, discordio=db_guild.discordio, - webhook_icon=db_guild.webhook_icon, + guest_icon=db_guild.guest_icon, ) @admin.route("/guilds") diff --git a/webapp/titanembeds/blueprints/api/api.py b/webapp/titanembeds/blueprints/api/api.py index 92cfcc5..76f2fdd 100644 --- a/webapp/titanembeds/blueprints/api/api.py +++ b/webapp/titanembeds/blueprints/api/api.py @@ -251,7 +251,7 @@ def post(): avatar = url_for('static', filename='img/titanembeds_square.png', _external=True) dbguild = db.session.query(Guilds).filter(Guilds.guild_id == guild_id).first() if dbguild: - icon = dbguild.webhook_icon + icon = dbguild.guest_icon if icon: avatar = icon else: diff --git a/webapp/titanembeds/blueprints/user/user.py b/webapp/titanembeds/blueprints/user/user.py index 42ba9e1..ab2ff4c 100644 --- a/webapp/titanembeds/blueprints/user/user.py +++ b/webapp/titanembeds/blueprints/user/user.py @@ -210,7 +210,7 @@ def administrate_guild(guild_id): "mentions_limit": db_guild.mentions_limit, "icon": db_guild.icon, "discordio": db_guild.discordio if db_guild.discordio != None else "", - "webhook_icon": db_guild.webhook_icon if db_guild.webhook_icon != None else "", + "guest_icon": db_guild.guest_icon if db_guild.guest_icon != None else "", } return render_template("administrate_guild.html.j2", guild=dbguild_dict, members=users, permissions=permissions, cosmetics=cosmetics) @@ -236,10 +236,10 @@ def update_administrate_guild(guild_id): discordio = None db_guild.discordio = discordio - webhook_icon = request.form.get("webhook_icon", db_guild.webhook_icon) - if webhook_icon != None and webhook_icon.strip() == "": - webhook_icon = None - db_guild.webhook_icon = webhook_icon + guest_icon = request.form.get("guest_icon", db_guild.guest_icon) + if guest_icon != None and guest_icon.strip() == "": + guest_icon = None + db_guild.guest_icon = guest_icon db.session.commit() return jsonify( @@ -252,7 +252,7 @@ def update_administrate_guild(guild_id): bracket_links=db_guild.bracket_links, mentions_limit=db_guild.mentions_limit, discordio=db_guild.discordio, - webhook_icon=webhook_icon, + guest_icon=guest_icon, ) @user.route("/add-bot/") @@ -444,9 +444,9 @@ def donate_patch(): entry = db.session.query(Cosmetics).filter(Cosmetics.user_id == session["user_id"]).first() if item == "custom_css_slots": subtract_amt = 100 - if item == "webhook_icon": + if item == "guest_icon": subtract_amt = 300 - if entry is not None and entry.webhook_icon: + if entry is not None and entry.guest_icon: abort(400) amt_change = -1 * subtract_amt * amount subtract = set_titan_token(session["user_id"], amt_change, "BUY " + item + " x" + str(amount)) @@ -459,10 +459,10 @@ def donate_patch(): entry.css = True entry.css_limit = 0 entry.css_limit += amount - if item == "webhook_icon": + if item == "guest_icon": if not entry: entry = Cosmetics(session["user_id"]) - entry.webhook_icon = True + entry.guest_icon = True db.session.add(entry) db.session.commit() return ('', 204) \ No newline at end of file diff --git a/webapp/titanembeds/database/cosmetics.py b/webapp/titanembeds/database/cosmetics.py index df225ac..7b1acd8 100644 --- a/webapp/titanembeds/database/cosmetics.py +++ b/webapp/titanembeds/database/cosmetics.py @@ -6,7 +6,7 @@ class Cosmetics(db.Model): user_id = db.Column(db.String(255), nullable=False) # Discord user id of user of cosmetics css = db.Column(db.Boolean(), nullable=False) # If they can create/edit custom CSS css_limit = db.Column(db.Integer, nullable=False, server_default="0") # Custom CSS Limit - webhook_icon = db.Column(db.Boolean(), nullable=False, server_default=db.false()) # If they can set the webhook icon for all guilds + guest_icon = db.Column(db.Boolean(), nullable=False, server_default=db.false()) # If they can set the guest icon for all guilds def __init__(self, user_id, **kwargs): self.user_id = user_id @@ -21,7 +21,7 @@ class Cosmetics(db.Model): else: self.css_limit = 0 - if "webhook_icon" in kwargs: - self.webhook_icon = kwargs["webhook_icon"] + if "guest_icon" in kwargs: + self.guest_icon = kwargs["guest_icon"] else: - self.webhook_icon = False \ No newline at end of file + self.guest_icon = False \ No newline at end of file diff --git a/webapp/titanembeds/database/guilds.py b/webapp/titanembeds/database/guilds.py index 980521d..537afc9 100644 --- a/webapp/titanembeds/database/guilds.py +++ b/webapp/titanembeds/database/guilds.py @@ -8,7 +8,7 @@ class Guilds(db.Model): unauth_users = db.Column(db.Boolean(), nullable=False, default=1) # If allowed unauth users visitor_view = db.Column(db.Boolean(), nullable=False, default=0) # If users are automatically "signed in" and can view chat webhook_messages = db.Column(db.Boolean(), nullable=False, default=0) # Use webhooks to send messages instead of the bot - webhook_icon = db.Column(db.String(255), default=None) # Webhook icon url, None if unset + guest_icon = db.Column(db.String(255), default=None) # Guest icon url, None if unset chat_links = db.Column(db.Boolean(), nullable=False, default=1) # If users can post links bracket_links = db.Column(db.Boolean(), nullable=False, default=1) # If appending brackets to links to prevent embed mentions_limit = db.Column(db.Integer, nullable=False, default=11) # If there is a limit on the number of mentions in a msg @@ -26,7 +26,7 @@ class Guilds(db.Model): self.unauth_users = True # defaults to true self.visitor_view = False self.webhook_messages = False - self.webhook_icon = None + self.guest_icon = None self.chat_links = True self.bracket_links = True self.mentions_limit = -1 # -1 = unlimited mentions diff --git a/webapp/titanembeds/static/js/admin_cosmetics.js b/webapp/titanembeds/static/js/admin_cosmetics.js index 14c4837..33837b7 100644 --- a/webapp/titanembeds/static/js/admin_cosmetics.js +++ b/webapp/titanembeds/static/js/admin_cosmetics.js @@ -1,13 +1,13 @@ /* global $, Materialize, location */ -function postForm(user_id, css, css_limit, webhook_icon) { +function postForm(user_id, css, css_limit, guest_icon) { if (css_limit == "") { css_limit = 0; } var funct = $.ajax({ dataType: "json", method: "POST", - data: {"user_id": user_id, "css": css, "css_limit": css_limit, "webhook_icon": webhook_icon} + data: {"user_id": user_id, "css": css, "css_limit": css_limit, "guest_icon": guest_icon} }); return funct.promise(); } @@ -40,8 +40,8 @@ $(function() { } var css_checked = $("#new_css_switch").is(':checked'); var css_limit = $("#new_css_limit").val(); - var webhook_icon_checked = $("#new_webhook_icon_switch").is(':checked'); - var formPost = postForm(user_id, css_checked, css_limit, webhook_icon_checked); + var guest_icon_checked = $("#new_guest_icon_switch").is(':checked'); + var formPost = postForm(user_id, css_checked, css_limit, guest_icon_checked); formPost.done(function (data) { location.reload(); }); @@ -101,9 +101,9 @@ function update_css_limit(user_id, value) { }); } -function update_webhook_icon_switch(user_id, element) { +function update_guest_icon_switch(user_id, element) { var webhook_checked = $(element).is(':checked'); - var formPatch = patchForm(user_id, {"webhook_icon": webhook_checked}); + var formPatch = patchForm(user_id, {"guest_icon": webhook_checked}); formPatch.done(function (data) { Materialize.toast('Webhook Icon updated!', 10000); }); diff --git a/webapp/titanembeds/static/js/administrate_guild.js b/webapp/titanembeds/static/js/administrate_guild.js index 59a384d..041f413 100644 --- a/webapp/titanembeds/static/js/administrate_guild.js +++ b/webapp/titanembeds/static/js/administrate_guild.js @@ -65,13 +65,13 @@ $("#discordio").keyup(function(event){ } }); -$("#webhook_icon").keyup(function(event){ +$("#guest_icon").keyup(function(event){ if(event.keyCode == 13){ var pathname = window.location.pathname; - var value = $("#webhook_icon").val() - var payload = {"webhook_icon": value} + var value = $("#guest_icon").val() + var payload = {"guest_icon": value} $.post(pathname, payload, function(data) { - Materialize.toast('Updated Webhook Icon setting!', 2000) + Materialize.toast('Updated Guest Icon setting!', 2000) }); } }); diff --git a/webapp/titanembeds/static/js/donate.js b/webapp/titanembeds/static/js/donate.js index 378174d..54b7a8e 100644 --- a/webapp/titanembeds/static/js/donate.js +++ b/webapp/titanembeds/static/js/donate.js @@ -47,10 +47,10 @@ }); }); - $("#buy-webhook-guest-user-avatar-btn").click(function () { - var formPatch = patchForm("webhook_icon", 1); + $("#buy-guest-user-avatar-btn").click(function () { + var formPatch = patchForm("guest_icon", 1); formPatch.done(function (data) { - alert("Successfully bought webhook guest user avatar perk!"); + alert("Successfully bought guest user avatar perk!"); location.reload(); }); formPatch.fail(function (data) { @@ -59,7 +59,7 @@ } else if (data.status == 402) { Materialize.toast('Insufficient token funds!', 10000); } else { - Materialize.toast('Purchasing webhook guest user avatar perk failed!', 10000); + Materialize.toast('Purchasing guest user avatar perk failed!', 10000); } }); }); diff --git a/webapp/titanembeds/templates/admin_cosmetics.html.j2 b/webapp/titanembeds/templates/admin_cosmetics.html.j2 index 56266ff..70db705 100644 --- a/webapp/titanembeds/templates/admin_cosmetics.html.j2 +++ b/webapp/titanembeds/templates/admin_cosmetics.html.j2 @@ -14,7 +14,7 @@ User ID CSS CSS Limit - Webhook Icon + Guest Icon Submit @@ -44,7 +44,7 @@
@@ -68,7 +68,7 @@ User ID CSS CSS Limit - Webhook Icon + Guest Icon @@ -95,7 +95,7 @@
diff --git a/webapp/titanembeds/templates/administrate_guild.html.j2 b/webapp/titanembeds/templates/administrate_guild.html.j2 index a598ca4..393f9bc 100644 --- a/webapp/titanembeds/templates/administrate_guild.html.j2 +++ b/webapp/titanembeds/templates/administrate_guild.html.j2 @@ -115,13 +115,13 @@
-

Webhook Guest User Avatar URL

-

If enabled Webhook Messages, you may set it so that the guest users may have a custom avatar instead of the Titan logo. Source must be the permanent URL location to the image file (try imgur and get direct link to image).

+

Guest User Avatar URL

+

Guest users may have a custom avatar instead of the Titan logo. Source must be the permanent URL location to the image file (try imgur and get direct link to image).

(Leave blank if none - enter to submit)

- {% if not cosmetics.webhook_icon %} -

Your user account does not have access to change webhook avatar url. Please visit the Titan Tokens shop to activate this cosmetic item.

+ {% if not cosmetics.guest_icon %} +

Your user account does not have access to change guest avatar url. Please visit the Titan Tokens shop to activate this cosmetic item.

{% endif %} - +
diff --git a/webapp/titanembeds/templates/donate.html.j2 b/webapp/titanembeds/templates/donate.html.j2 index 9c5e68c..8097318 100644 --- a/webapp/titanembeds/templates/donate.html.j2 +++ b/webapp/titanembeds/templates/donate.html.j2 @@ -47,10 +47,10 @@
-

Webhook Guest User Avatar [300 tokens]

-

Tired of the bland Titan logo for your guests avatars in your servers? Enables your account to be able to set webhook icons for guests for all servers you can manage.

-

(Note: Webhook Messages has to be enabled & Titan needs server permissions to create webhooks)

- {% if cosmetics.webhook_icon %}Already Purchased{% else %}Buy{% endif %} +

Guest User Avatar [300 tokens]

+

Tired of the bland Titan logo for your guests avatars in your servers? Enables your account to be able to set icons for guests on all servers you can manage.

+

(Note: Webhook Messages has to be enabled to be displayed in Discord; Titan needs server permissions to create webhooks)

+ {% if cosmetics.guest_icon %}Already Purchased{% else %}Buy{% endif %}