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
config.py
__pycache__
src_audio/
src_audio/
node_modules

View File

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

12
app.py
View File

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

View File

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

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,7 +17,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.10.1\n"
#: templates/base.html:15
#: templates/base.html:17
msgid "Welcome"
msgstr ""
@ -25,11 +25,27 @@ msgstr ""
msgid "Welcome to BirdQuizz !"
msgstr ""
#: templates/menu.html:3
#: templates/menu.html:7
msgid "Home"
msgstr ""
#: templates/menu.html:4
#: templates/menu.html:8
msgid "Game"
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 ""
"Project-Id-Version: PROJECT VERSION\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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: fr\n"
@ -18,7 +18,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.10.1\n"
#: templates/base.html:15
#: templates/base.html:17
msgid "Welcome"
msgstr "Bienvenue"
@ -26,11 +26,54 @@ msgstr "Bienvenue"
msgid "Welcome to BirdQuizz !"
msgstr "Bienvenue au BirdQuizz !"
#: templates/menu.html:3
#: templates/menu.html:7
msgid "Home"
msgstr "Accueil"
#: templates/menu.html:4
#: templates/menu.html:8
msgid "Game"
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 {
background-color: black;
color: white;
main {
min-height: 100vh;
}
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