diff --git a/database/models.py b/database/models.py index e3eb3f3..1cfca05 100644 --- a/database/models.py +++ b/database/models.py @@ -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)) diff --git a/database/schema.sql b/database/schema.sql index c73b09c..24ff873 100644 --- a/database/schema.sql +++ b/database/schema.sql @@ -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, diff --git a/webapp/__init__.py b/webapp/__init__.py index d011c17..8620413 100644 --- a/webapp/__init__.py +++ b/webapp/__init__.py @@ -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 diff --git a/webapp/configurations.py b/webapp/configurations.py index cfc617b..5578e3e 100644 --- a/webapp/configurations.py +++ b/webapp/configurations.py @@ -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(): diff --git a/webapp/protondb.py b/webapp/protondb.py new file mode 100644 index 0000000..04cf6a9 --- /dev/null +++ b/webapp/protondb.py @@ -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/') +def delGameAlias(id : int): + GameAlias.query.filter_by(id=id).delete() + db.session.commit() + return redirect(url_for('protondb')) + diff --git a/webapp/templates/configurations.html b/webapp/templates/configurations.html index 2dfa7cc..014c832 100644 --- a/webapp/templates/configurations.html +++ b/webapp/templates/configurations.html @@ -21,24 +21,6 @@ -

Proton DB

-
- - - - - - - - -

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), - comme le montre cet exemple -

-
-

Api Discord

diff --git a/webapp/templates/protondb.html b/webapp/templates/protondb.html new file mode 100644 index 0000000..812e4ea --- /dev/null +++ b/webapp/templates/protondb.html @@ -0,0 +1,55 @@ +{% extends "template.html" %} + +{% block content %} +

Proton DB

+ +

Game alias

+ + + + + + + + + + {% for a in aliases %} + + + + + + {% endfor %} + +
AliasGame#
{{a.alias}}{{a.name}}Supprimer
+ +

Ajouter un Alias

+ + + + + + +

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**.

+
+ +

Configuration

+
+ + + + + + + + +

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), + comme le montre cet exemple +

+
+{% endblock %} \ No newline at end of file diff --git a/webapp/templates/template.html b/webapp/templates/template.html index 7e12769..04db3d0 100644 --- a/webapp/templates/template.html +++ b/webapp/templates/template.html @@ -22,6 +22,7 @@
  • Humeurs
  • Messages
  • Modération
  • +
  • ProtonDB
  • Configurations
  • @@ -35,4 +36,4 @@ - + \ No newline at end of file