mirror of
https://github.com/skylanix/MamieHenriette.git
synced 2026-02-14 12:10:38 +01:00
configuration humble bundle
This commit is contained in:
@@ -2,27 +2,24 @@ from flask import render_template, request, redirect, url_for
|
||||
from webapp import webapp
|
||||
from database import db
|
||||
from database.models import Configuration
|
||||
from database.helpers import ConfigurationHelper
|
||||
from discordbot import bot
|
||||
from discord import TextChannel
|
||||
|
||||
@webapp.route("/configurations")
|
||||
def openConfigurations():
|
||||
all = Configuration.query.all()
|
||||
configurations = {conf.key: conf for conf in all}
|
||||
return render_template("configurations.html", configurations = configurations, channels = bot.get_all_channels())
|
||||
channels = []
|
||||
for channel in bot.get_all_channels():
|
||||
if isinstance(channel, TextChannel):
|
||||
channels.append(channel)
|
||||
return render_template("configurations.html", configuration = ConfigurationHelper(), channels = channels)
|
||||
|
||||
@webapp.route("/updateConfiguration", methods=['POST'])
|
||||
@webapp.route("/configurations/update", methods=['POST'])
|
||||
def updateConfiguration():
|
||||
|
||||
return redirect(url_for('openConfigurations'))
|
||||
|
||||
|
||||
@webapp.route('/configurations/set/<key>', methods=['POST'])
|
||||
def setConfiguration(key):
|
||||
conf = Configuration.query.filter_by(key=key).first()
|
||||
if conf :
|
||||
conf.value = request.form['value']
|
||||
else :
|
||||
conf = Configuration(key = key, value = request.form['value'])
|
||||
db.session.add(conf)
|
||||
for key in request.form :
|
||||
ConfigurationHelper().createOrUpdate(key, request.form.get(key))
|
||||
if (request.form.get("humble_bundle_channel") != None and request.form.get("humble_bundle_enable") == None) :
|
||||
ConfigurationHelper().createOrUpdate('humble_bundle_enable', False)
|
||||
db.session.commit()
|
||||
return redirect(url_for('openConfigurations'))
|
||||
|
||||
Reference in New Issue
Block a user