mirror of
https://github.com/skylanix/MamieHenriette.git
synced 2026-02-06 14:50:34 +01:00
Page d'edition proton DB
This commit is contained in:
@@ -9,6 +9,11 @@ class Humeur(db.Model):
|
||||
enable = db.Column(db.Boolean, default=True)
|
||||
text = db.Column(db.String(256))
|
||||
|
||||
class GameAlias(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
alias = db.Column(db.String(32))
|
||||
name = db.Column(db.String(256))
|
||||
|
||||
class GameBundle(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.String(256))
|
||||
|
||||
@@ -4,6 +4,12 @@ CREATE TABLE IF NOT EXISTS `configuration` (
|
||||
`value` VARCHAR(512) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `game_alias` (
|
||||
id INTEGER PRIMARY KEY,
|
||||
alias VARCHAR(32) UNIQUE NOT NULL,
|
||||
`name` VARCHAR(256) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `game_bundle` (
|
||||
id INTEGER PRIMARY KEY,
|
||||
name VARCHAR(256) NOT NULL,
|
||||
|
||||
@@ -2,4 +2,4 @@ from flask import Flask
|
||||
|
||||
webapp = Flask(__name__)
|
||||
|
||||
from webapp import commandes, configurations, index, humeurs, messages, moderation
|
||||
from webapp import commandes, configurations, index, humeurs, messages, moderation, protondb
|
||||
|
||||
@@ -23,7 +23,7 @@ def updateConfiguration():
|
||||
if (request.form.get("proton_db_api_id") != None and request.form.get("proton_db_enable_enable") == None) :
|
||||
ConfigurationHelper().createOrUpdate('proton_db_enable_enable', False)
|
||||
db.session.commit()
|
||||
return redirect(url_for('openConfigurations'))
|
||||
return redirect(request.referrer)
|
||||
|
||||
@webapp.route("/configurations/twitch/help")
|
||||
def twitchConfigurationHelp():
|
||||
|
||||
24
webapp/protondb.py
Normal file
24
webapp/protondb.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from flask import render_template, request, redirect, url_for
|
||||
from webapp import webapp
|
||||
from database import db
|
||||
from database.models import GameAlias
|
||||
from database.helpers import ConfigurationHelper
|
||||
|
||||
@webapp.route("/protondb")
|
||||
def openProtonDB():
|
||||
aliases = GameAlias.query.all()
|
||||
return render_template("protondb.html", aliases = aliases, configuration = ConfigurationHelper())
|
||||
|
||||
@webapp.route("/protondb/gamealias/add", methods=['POST'])
|
||||
def addGameAlias():
|
||||
game_alias = GameAlias(alias = request.form.get('alias'), name = request.form.get('name'))
|
||||
db.session.add(game_alias)
|
||||
db.session.commit()
|
||||
return redirect(url_for('openProtonDB'))
|
||||
|
||||
@webapp.route('/protondb/gamealias/del/<int:id>')
|
||||
def delGameAlias(id : int):
|
||||
GameAlias.query.filter_by(id=id).delete()
|
||||
db.session.commit()
|
||||
return redirect(url_for('protondb'))
|
||||
|
||||
@@ -21,24 +21,6 @@
|
||||
<input type="Submit" value="Définir">
|
||||
</form>
|
||||
|
||||
<h2>Proton DB</h2>
|
||||
<form action="{{ url_for('updateConfiguration') }}" method="POST">
|
||||
<label for="proton_db_enable_enable">Activer</label>
|
||||
<input type="checkbox" name="proton_db_enable_enable" {% if configuration.getValue('proton_db_enable_enable') %}
|
||||
checked="checked" {% endif %}>
|
||||
<label>Activer la commande Proton DB</label>
|
||||
<label for="proton_db_api_id">Api ID</label>
|
||||
<input name="proton_db_api_id" type="text" value="{{ configuration.getValue('proton_db_api_id') }}" />
|
||||
<label for="proton_db_api_key">Api KEY</label>
|
||||
<input name="proton_db_api_key" type="text" value="{{ configuration.getValue('proton_db_api_key') }}" />
|
||||
<input type="Submit" value="Définir">
|
||||
<p>Pour trouver les clés, dans votre navigateur avec l'outil d'inspection ouvert (F12 ou clic droit > Inspecter
|
||||
l'élément dans Firefox/Chrome) faites une recherche de jeux sur protondb,
|
||||
puis chercher les clés dans les requêtes (onglet Réseau/Network),
|
||||
<a href="/static/img/algolia-key.jpg" target="_blank">comme le montre cet exemple</a>
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<h2>Api Discord</h2>
|
||||
<form action="{{ url_for('updateConfiguration') }}" method="POST">
|
||||
<label for="discord_token">Api Discord (cachée)</label>
|
||||
|
||||
55
webapp/templates/protondb.html
Normal file
55
webapp/templates/protondb.html
Normal file
@@ -0,0 +1,55 @@
|
||||
{% extends "template.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Proton DB</h1>
|
||||
|
||||
<h2>Game alias</h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Alias</th>
|
||||
<th>Game</th>
|
||||
<th>#</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for a in aliases %}
|
||||
<tr>
|
||||
<td>{{a.alias}}</td>
|
||||
<td>{{a.name}}</td>
|
||||
<td><a href="{{ url_for('delGameAlias', id = a.id) }}"
|
||||
onclick="return confirm('Êtes-vous sûr de vouloir supprimer cet alias ?')">Supprimer</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h2>Ajouter un Alias</h2>
|
||||
<form action="{{ url_for('addGameAlias') }}" method="POST">
|
||||
<label for="alias">Alias</label>
|
||||
<input name="alias" type="text" maxlength="32" required="required" />
|
||||
<label for="name">Nom</label>
|
||||
<input name="name" type="text" maxlength="256" required="required" />
|
||||
<input type="Submit" value="Ajouter">
|
||||
<p>Si vous créer un *game alias* **GTA > Grand Theft Auto** alors si un utilisateur rentre la commande **!protondb
|
||||
GTA 5** cela fera une recherche sur **Grand Theft Auto 5**.</p>
|
||||
</form>
|
||||
|
||||
<h2>Configuration</h2>
|
||||
<form action="{{ url_for('updateConfiguration') }}" method="POST">
|
||||
<label for="proton_db_enable_enable">Activer</label>
|
||||
<input type="checkbox" name="proton_db_enable_enable" {% if configuration.getValue('proton_db_enable_enable') %}
|
||||
checked="checked" {% endif %}>
|
||||
<label>Activer la commande Proton DB</label>
|
||||
<label for="proton_db_api_id">Api ID</label>
|
||||
<input name="proton_db_api_id" type="text" value="{{ configuration.getValue('proton_db_api_id') }}" />
|
||||
<label for="proton_db_api_key">Api KEY</label>
|
||||
<input name="proton_db_api_key" type="text" value="{{ configuration.getValue('proton_db_api_key') }}" />
|
||||
<input type="Submit" value="Définir">
|
||||
<p>Pour trouver les clés, dans votre navigateur avec l'outil d'inspection ouvert (F12 ou clic droit > Inspecter
|
||||
l'élément dans Firefox/Chrome) faites une recherche de jeux sur protondb,
|
||||
puis chercher les clés dans les requêtes (onglet Réseau/Network),
|
||||
<a href="/static/img/algolia-key.jpg" target="_blank">comme le montre cet exemple</a>
|
||||
</p>
|
||||
</form>
|
||||
{% endblock %}
|
||||
@@ -22,6 +22,7 @@
|
||||
<li><a href="/humeurs">Humeurs</a></li>
|
||||
<li><a href="/messages">Messages</a></li>
|
||||
<li><a href="/moderation">Modération</a></li>
|
||||
<li><a href="/protondb">ProtonDB</a></li>
|
||||
<li><a href="/configurations">Configurations</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
Reference in New Issue
Block a user