Refont de l'interface configuration.html

This commit is contained in:
Mow
2025-10-16 20:37:38 +02:00
parent 6a171e795f
commit 2815022219
2 changed files with 87 additions and 86 deletions

View File

@@ -10,23 +10,23 @@ def openConfigurations():
@webapp.route("/configurations/update", methods=['POST']) @webapp.route("/configurations/update", methods=['POST'])
def updateConfiguration(): def updateConfiguration():
for key in request.form : checkboxes = {
'humble_bundle_enable': 'humble_bundle_channel',
'proton_db_enable_enable': 'proton_db_api_id',
'moderation_enable': 'moderation_staff_role_id',
'moderation_ban_enable': 'moderation_staff_role_id',
'moderation_kick_enable': 'moderation_staff_role_id',
'welcome_enable': 'welcome_channel_id',
'leave_enable': 'leave_channel_id'
}
for key in request.form:
ConfigurationHelper().createOrUpdate(key, request.form.get(key)) ConfigurationHelper().createOrUpdate(key, request.form.get(key))
# Je fais ça car HTML n'envoie pas le paramètre de checkbox quand il est décoché
if (request.form.get("humble_bundle_channel") != None and request.form.get("humble_bundle_enable") == None) : for checkbox, reference_field in checkboxes.items():
ConfigurationHelper().createOrUpdate('humble_bundle_enable', False) if request.form.get(reference_field) is not None and request.form.get(checkbox) is None:
if (request.form.get("proton_db_api_id") != None and request.form.get("proton_db_enable_enable") == None) : ConfigurationHelper().createOrUpdate(checkbox, False)
ConfigurationHelper().createOrUpdate('proton_db_enable_enable', False)
if (request.form.get("moderation_staff_role_id") != None and request.form.get("moderation_enable") == None) :
ConfigurationHelper().createOrUpdate('moderation_enable', False)
if (request.form.get("moderation_staff_role_id") != None and request.form.get("moderation_ban_enable") == None) :
ConfigurationHelper().createOrUpdate('moderation_ban_enable', False)
if (request.form.get("moderation_staff_role_id") != None and request.form.get("moderation_kick_enable") == None) :
ConfigurationHelper().createOrUpdate('moderation_kick_enable', False)
if (request.form.get("welcome_channel_id") != None and request.form.get("welcome_enable") == None) :
ConfigurationHelper().createOrUpdate('welcome_enable', False)
if (request.form.get("leave_channel_id") != None and request.form.get("leave_enable") == None) :
ConfigurationHelper().createOrUpdate('leave_enable', False)
db.session.commit() db.session.commit()
return redirect(request.referrer) return redirect(request.referrer)

View File

@@ -2,82 +2,83 @@
{% block content %} {% block content %}
<h1>Configuration de Mamie</h1> <h1>Configuration de Mamie</h1>
<p>Configurez les tokens Discord, les notifications Humble Bundle et l'API ProtonDB pour la commande !protondb.</p> <p>Configurez les tokens Discord, les notifications Humble Bundle et l'API Twitch.</p>
<h2>Discord</h2> <h2>Discord</h2>
<h3>API Discord</h3>
<form action="{{ url_for('updateConfiguration') }}" method="POST"> <form action="{{ url_for('updateConfiguration') }}" method="POST">
<label for="discord_token">API Discord (cachée)</label> <fieldset>
<input name="discord_token" type="password" /> <legend>API Discord</legend>
<input type="Submit" value="Définir"> <label for="discord_token">Token Discord (caché)</label>
<p>Nécessite un redémarrage</p> <input name="discord_token" type="password" placeholder="Votre token Discord" />
</form> <small>Nécessite un redémarrage après modification</small>
</fieldset>
<fieldset>
<legend>Messages de bienvenue</legend>
<label for="welcome_enable">
<input type="checkbox" name="welcome_enable" {% if configuration.getValue('welcome_enable') %}checked="checked"{% endif %}>
Activer le message de bienvenue pour les nouveaux membres
</label>
<h3>Message de bienvenue Discord</h3>
<form action="{{ url_for('updateConfiguration') }}" method="POST">
<label for="welcome_enable">Activer</label>
<input type="checkbox" name="welcome_enable" {% if configuration.getValue('welcome_enable') %}
checked="checked" {% endif %}>
<label>Activer le message de bienvenue pour les nouveaux membres</label>
<label for="welcome_channel_id">Canal de bienvenue</label> <label for="welcome_channel_id">Canal de bienvenue</label>
<select name="welcome_channel_id"> <select name="welcome_channel_id">
{% for channel in channels %} {% for channel in channels %}
<option value="{{channel.id}}" {% if configuration.getIntValue('welcome_channel_id')==channel.id %} <option value="{{channel.id}}" {% if configuration.getIntValue('welcome_channel_id')==channel.id %}selected="selected"{% endif %}>
selected="selected" {% endif %}> {{channel.name}}
{{channel.name}}</option> </option>
{% endfor %} {% endfor %}
</select> </select>
<label for="welcome_message">Message personnalisé</label>
<textarea name="welcome_message" rows="4" placeholder="Bienvenue sur le serveur !">{{ configuration.getValue('welcome_message') }}</textarea>
<input type="Submit" value="Définir">
</form>
<h3>Message de départ Discord</h3> <label for="welcome_message">Message personnalisé de bienvenue</label>
<form action="{{ url_for('updateConfiguration') }}" method="POST"> <textarea name="welcome_message" rows="3" placeholder="Bienvenue sur le serveur !">{{ configuration.getValue('welcome_message') }}</textarea>
<label for="leave_enable">Activer</label> </fieldset>
<input type="checkbox" name="leave_enable" {% if configuration.getValue('leave_enable') %}
checked="checked" {% endif %}> <fieldset>
<label>Activer le message de départ quand un membre quitte le serveur</label> <legend>Messages de départ</legend>
<label for="leave_enable">
<input type="checkbox" name="leave_enable" {% if configuration.getValue('leave_enable') %}checked="checked"{% endif %}>
Activer le message de départ quand un membre quitte le serveur
</label>
<label for="leave_channel_id">Canal de départ</label> <label for="leave_channel_id">Canal de départ</label>
<select name="leave_channel_id"> <select name="leave_channel_id">
{% for channel in channels %} {% for channel in channels %}
<option value="{{channel.id}}" {% if configuration.getIntValue('leave_channel_id')==channel.id %} <option value="{{channel.id}}" {% if configuration.getIntValue('leave_channel_id')==channel.id %}selected="selected"{% endif %}>
selected="selected" {% endif %}> {{channel.name}}
{{channel.name}}</option> </option>
{% endfor %} {% endfor %}
</select> </select>
<label for="leave_message">Message personnalisé</label>
<textarea name="leave_message" rows="4" placeholder="Un membre a quitté le serveur.">{{ configuration.getValue('leave_message') }}</textarea>
<input type="Submit" value="Définir">
</form>
<h3>Modération Discord</h3> <label for="leave_message">Message personnalisé de départ</label>
<form action="{{ url_for('updateConfiguration') }}" method="POST"> <textarea name="leave_message" rows="3" placeholder="Un membre a quitté le serveur.">{{ configuration.getValue('leave_message') }}</textarea>
<label for="moderation_enable">Activer les avertissements</label> </fieldset>
<input type="checkbox" name="moderation_enable" {% if configuration.getValue('moderation_enable') %}
checked="checked" {% endif %}>
<label>Activer les commandes d'avertissement (!averto, !delaverto, !listaverto)</label>
<label for="moderation_ban_enable">Activer le ban</label> <fieldset>
<input type="checkbox" name="moderation_ban_enable" {% if configuration.getValue('moderation_ban_enable') %} <legend>Modération</legend>
checked="checked" {% endif %}> <label for="moderation_enable">
<label>Activer les commandes de bannissement (!ban, !unban)</label> <input type="checkbox" name="moderation_enable" {% if configuration.getValue('moderation_enable') %}checked="checked"{% endif %}>
Activer les commandes d'avertissement (!averto, !delaverto, !listaverto)
</label>
<label for="moderation_kick_enable">Activer le kick</label> <label for="moderation_ban_enable">
<input type="checkbox" name="moderation_kick_enable" {% if configuration.getValue('moderation_kick_enable') %} <input type="checkbox" name="moderation_ban_enable" {% if configuration.getValue('moderation_ban_enable') %}checked="checked"{% endif %}>
checked="checked" {% endif %}> Activer les commandes de bannissement (!ban, !unban)
<label>Activer la commande d'expulsion (!kick)</label> </label>
<label for="moderation_kick_enable">
<input type="checkbox" name="moderation_kick_enable" {% if configuration.getValue('moderation_kick_enable') %}checked="checked"{% endif %}>
Activer la commande d'expulsion (!kick)
</label>
<label for="moderation_staff_role_id">ID du rôle Staff</label> <label for="moderation_staff_role_id">ID du rôle Staff</label>
<input name="moderation_staff_role_id" type="text" value="{{ configuration.getValue('moderation_staff_role_id') }}" <input name="moderation_staff_role_id" type="text" value="{{ configuration.getValue('moderation_staff_role_id') }}" placeholder="581990740431732738" />
placeholder="581990740431732738" />
<label for="moderation_embed_delete_delay">Délai de suppression des embeds (en secondes, 0 = ne pas supprimer)</label> <label for="moderation_embed_delete_delay">Délai de suppression des embeds (en secondes)</label>
<input name="moderation_embed_delete_delay" type="number" value="{{ configuration.getValue('moderation_embed_delete_delay') or '0' }}" <input name="moderation_embed_delete_delay" type="number" value="{{ configuration.getValue('moderation_embed_delete_delay') or '0' }}" placeholder="0" min="0" />
placeholder="0" min="0" /> <small>Mettre 0 pour ne pas supprimer automatiquement</small>
</fieldset>
<input type="Submit" value="Définir"> <input type="Submit" value="Enregistrer la configuration Discord">
</form> </form>
<h2>API Twitch</h2> <h2>API Twitch</h2>