This commit is contained in:
Samuel Ortion 2022-05-27 10:08:25 +02:00
parent 3e80e68da7
commit c9d4c335ab
11 changed files with 93 additions and 26 deletions

3
.gitignore vendored
View File

@ -1,4 +1,5 @@
venv venv
config.py config.py
__pycache__ __pycache__
src_audio/ src_audio/
node_modules

View File

@ -33,11 +33,6 @@ cp config.py.example config.py
## Database migration ## Database migration
```bash ```bash
python3 flask db migrate -m "Migration message."
``` flask db upgrade # Perform migration (after script verification in ./migrations/versions/)
```python3
from app import *
app.app_context().push()
db.create_all()
``` ```

12
app.py
View File

@ -42,14 +42,15 @@ def get_timezone():
if user is not None: if user is not None:
return user.timezone return user.timezone
app.jinja_env.globals['get_locale'] = get_locale
@app.route('/lang') @app.route('/lang')
def get_lang(): def get_lang():
return render_template('lang.html') return render_template('lang.html')
@app.route('/lang', methods=["POST"]) @app.route('/lang/<locale>')
def set_lang(): def set_lang(locale='en'):
lang = request.form["lang"] session['lang'] = locale
session['lang'] = lang
return redirect('/') return redirect('/')
@app.route("/") @app.route("/")
@ -140,8 +141,9 @@ def game_answer():
message = "You are correct !" message = "You are correct !"
else: else:
message = "You are not correct !" message = "You are not correct !"
return render_template("game/answer.html", message=message) return render_template("game/answer.html", message=message, question=session["question"])
elif request.method == "GET": elif request.method == "GET":
return render_template("game/new.html") return render_template("game/new.html")
migrate = Migrate(app, db) migrate = Migrate(app, db)

View File

@ -1,4 +1,3 @@
[python: **.py] [python: **.py]
[jinja2: templates/**.html] [jinja2: templates/**.html]
encoding = utf-8 encoding = utf-8
extensions=jinja2.ext.autoescape,jinja2.ext.with_

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PROJECT VERSION\n" "Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2022-05-26 12:11+0200\n" "POT-Creation-Date: 2022-05-27 10:03+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,7 +17,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.10.1\n" "Generated-By: Babel 2.10.1\n"
#: templates/base.html:15 #: templates/base.html:17
msgid "Welcome" msgid "Welcome"
msgstr "" msgstr ""
@ -25,11 +25,27 @@ msgstr ""
msgid "Welcome to BirdQuizz !" msgid "Welcome to BirdQuizz !"
msgstr "" msgstr ""
#: templates/menu.html:3 #: templates/menu.html:7
msgid "Home" msgid "Home"
msgstr "" msgstr ""
#: templates/menu.html:4 #: templates/menu.html:8
msgid "Game" msgid "Game"
msgstr "" msgstr ""
#: templates/menu.html:9
msgid "About"
msgstr ""
#: templates/menu.html:11
msgid "Logout"
msgstr ""
#: templates/menu.html:13
msgid "Login"
msgstr ""
#: templates/menu.html:15
msgid "Identify bird song"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PROJECT VERSION\n" "Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2022-05-26 12:11+0200\n" "POT-Creation-Date: 2022-05-27 10:03+0200\n"
"PO-Revision-Date: 2022-05-26 13:10+0200\n" "PO-Revision-Date: 2022-05-26 13:10+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: fr\n" "Language: fr\n"
@ -18,7 +18,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.10.1\n" "Generated-By: Babel 2.10.1\n"
#: templates/base.html:15 #: templates/base.html:17
msgid "Welcome" msgid "Welcome"
msgstr "Bienvenue" msgstr "Bienvenue"
@ -26,11 +26,54 @@ msgstr "Bienvenue"
msgid "Welcome to BirdQuizz !" msgid "Welcome to BirdQuizz !"
msgstr "Bienvenue au BirdQuizz !" msgstr "Bienvenue au BirdQuizz !"
#: templates/menu.html:3 #: templates/menu.html:7
msgid "Home" msgid "Home"
msgstr "Accueil" msgstr "Accueil"
#: templates/menu.html:4 #: templates/menu.html:8
msgid "Game" msgid "Game"
msgstr "Jeu" msgstr "Jeu"
#: templates/menu.html:9
msgid "About"
msgstr "À propos"
#: templates/menu.html:11
msgid "Logout"
msgstr "Déconnexion"
#: templates/menu.html:13
msgid "Login"
msgstr "Connexion"
#: templates/menu.html:15
msgid "Identify bird song"
msgstr "Indentifie les son d'oiseaux"
#~ msgid "Welcome"
#~ msgstr "Bienvenue"
#~ msgid "Welcome to BirdQuizz !"
#~ msgstr "Bienvenue au BirdQuizz !"
#~ msgid "Home"
#~ msgstr "Accueil"
#~ msgid "Game"
#~ msgstr "Jeu"
#~ msgid "Username empty. Try to find one."
#~ msgstr "Nom d'utilisateur vide. Essayez d'en trouver un."
#~ msgid "Email empty. Please give me one."
#~ msgstr "Email non fourmi. Merci de m'en envoyez un."
#~ msgid "You should not use an empty password"
#~ msgstr "Vous ne devriez pas utiliser un mot de passe vide."
#~ msgid "Email already used by a user."
#~ msgstr "Cet email a déjà été utilisé par quelqu'un."
#~ msgid "Username already used by a user."
#~ msgstr "Ce nom d'utilisateur a déjà été pris."

0
static/scripts/app.js Normal file
View File

View File

@ -1,4 +1,7 @@
body { main {
background-color: black; min-height: 100vh;
color: white; }
footer {
padding: 1em;
} }

4
utils/make_migration.sh Normal file
View File

@ -0,0 +1,4 @@
#!/bin/bash
flask db migrate -m "Initial migration."
flask db upgrade

View File

@ -0,0 +1,4 @@
#!/bin/sh
pybabel extract -F babel.cfg -o ./language/message.pot ./templates/**
pybabel update -i message.pot -d translations
pybabel compile -d translations