From 1f54bf99755956f3b514a7461abc2ee74bd0dbbe Mon Sep 17 00:00:00 2001 From: suruq Date: Mon, 26 Feb 2018 16:35:48 +0100 Subject: [PATCH 01/13] corrections mineur. --- app.db | Bin 32768 -> 32768 bytes app/routes.py | 12 ++ app/templates/base/navbar.html | 244 +-------------------------------- 3 files changed, 15 insertions(+), 241 deletions(-) diff --git a/app.db b/app.db index 358ace2e7f5d6ee918c2af3b9fff64da723f7492..a4fcc5a6793958b33f805aa61014d35b195d0ba6 100644 GIT binary patch delta 450 zcmXw#Jxd%>6o&829ha!<-Xthtjkp#|z{cF~JGWZVV%eaDTDV7cpq&d9j9Nvd>-q9!>jna$v$^7NYb~1nW<>q5OYe<03 z(Q4ziA@AS3{?J%F&1#^ze%2kB;^gS-w2rSjEB)|&=eXFy-`ZY!%_LSvJ7+PqQ7WNa za3UCvql+;RDU~tA8kuY9Irdlyj2+WnITi-629}y<-EvqA%gu6p-FbJQ>DH%y?{K$G zXzsiUK`Sk}h*advMjxoK-dQWS From 761a7ea512d9dd8bd378c817a713ac43980783fc Mon Sep 17 00:00:00 2001 From: Eragonfr Date: Thu, 12 Apr 2018 22:23:44 +0200 Subject: [PATCH 02/13] Page d'erreur minimale --- app/routes.py | 16 +++++++++++++--- app/templates/base/errors.html.j2 | 9 +++++++++ app/templates/base/navbar.html | 3 +-- 3 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 app/templates/base/errors.html.j2 diff --git a/app/routes.py b/app/routes.py index e368476..4f8d287 100644 --- a/app/routes.py +++ b/app/routes.py @@ -47,9 +47,6 @@ def register(): return redirect(url_for('validation')) return render_template('register.html', title='Register', form=form, form2 = form2) - - - @app.route('/register/validation/') def validation(): if current_user.is_authenticated : @@ -62,3 +59,16 @@ def validation(): return redirect(url_for('index')) login_user(user, remember=form.remember_me.data) return render_template('validation.html', form = form) + +@app.errorhandler(401) +@app.errorhandler(404) +@app.errorhandler(500) +def errors(error): + form = LoginForm() + if form.validate_on_submit(): + user = User.query.filter_by(username=form.username.data).first() + if user is None or not user.check_password(form.password.data): + flash('pseudo ou mot de passe invalide') + return redirect(url_for('index')) + login_user(user, remember=form.remember_me.data) + return render_template("base/errors.html.j2", error_code = error.code, form=form), error.code diff --git a/app/templates/base/errors.html.j2 b/app/templates/base/errors.html.j2 new file mode 100644 index 0000000..7025f70 --- /dev/null +++ b/app/templates/base/errors.html.j2 @@ -0,0 +1,9 @@ +{% extends "base/container.html" %} + +{% block content %} +
+
+

Oups erreur {{ error_code }}

+
+
+{% endblock %} diff --git a/app/templates/base/navbar.html b/app/templates/base/navbar.html index b4f9ca3..bcb2423 100644 --- a/app/templates/base/navbar.html +++ b/app/templates/base/navbar.html @@ -85,7 +85,6 @@ {% include "base/navbar/tools.html" %} {% if current_user.is_authenticated %} - - + {% endif %} From 2da7634951e652c2afb63c5498a7dffc7e3b5f02 Mon Sep 17 00:00:00 2001 From: Eragonfr Date: Sun, 15 Apr 2018 22:07:03 +0200 Subject: [PATCH 03/13] =?UTF-8?q?gestion=20de=20plusieurs=20erreurs=20avec?= =?UTF-8?q?=20des=20messages=20diff=C3=A9rents?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/routes.py | 11 ++++++++++- app/templates/base/errors.html | 26 ++++++++++++++++++++++++++ app/templates/base/errors.html.j2 | 9 --------- 3 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 app/templates/base/errors.html delete mode 100644 app/templates/base/errors.html.j2 diff --git a/app/routes.py b/app/routes.py index 4f8d287..7c7bcb6 100644 --- a/app/routes.py +++ b/app/routes.py @@ -60,9 +60,15 @@ def validation(): login_user(user, remember=form.remember_me.data) return render_template('validation.html', form = form) +@app.route('/error/') +@app.errorhandler(400) @app.errorhandler(401) +@app.errorhandler(403) @app.errorhandler(404) +@app.errorhandler(418) @app.errorhandler(500) +@app.errorhandler(501) +@app.errorhandler(503) def errors(error): form = LoginForm() if form.validate_on_submit(): @@ -71,4 +77,7 @@ def errors(error): flash('pseudo ou mot de passe invalide') return redirect(url_for('index')) login_user(user, remember=form.remember_me.data) - return render_template("base/errors.html.j2", error_code = error.code, form=form), error.code + try: + return render_template("base/errors.html.j2", error_code = error, form=form), error + except: + return render_template("base/errors.html.j2", error_code = error.code, form=form), error.code diff --git a/app/templates/base/errors.html b/app/templates/base/errors.html new file mode 100644 index 0000000..3d77bcd --- /dev/null +++ b/app/templates/base/errors.html @@ -0,0 +1,26 @@ +{% extends "base/container.html" %} + +{% block content %} +
+

Oups erreur {{ error_code }}

+ {% if error_code == 400 %} + Bad Request : Votre requète semble mal formée. + {% elif error_code == 401 %} + Unauthorized : Une authentification est nécessaire pour accéder à la ressource. +
+ Veuillez vous connecter à l'aide du panneau sur la gauche. + {% elif error_code == 403 %} + Forbidden : La page vous est interdit. + {% elif error_code == 404 %} + Not Found : La page n'existe pas ou plus, si vous avez rentré l'url à la main vérifiez de ne pas vous être trompé. + {% elif error_code == 418 %} + I’m a teapot : Je suis une théière + {% elif error_code == 500 %} + Internal Server Error : Erreur interne du serveur. Rassurez vous vous n'êtes pas en cause c'est sans doute un dévlopeur qui à fait l'imbécile. Si cette page s'affiche trop souvent essayez de contacter un administrateur par mail à devs@planet-casio.com. + {% elif error_code == 501 %} + Not Implemented : La fonctionnalité réclamée n'est pas supportée par le serveur. Désolé si cette fonctionnalité vous tient à cœur vous pouvez la proposer sur le forum. + {% elif error_code == 503 %} + Service Unavailable : Service temporairement indisponible ou en maintenance. Patientez! + {% endif %} +
+{% endblock %} diff --git a/app/templates/base/errors.html.j2 b/app/templates/base/errors.html.j2 deleted file mode 100644 index 7025f70..0000000 --- a/app/templates/base/errors.html.j2 +++ /dev/null @@ -1,9 +0,0 @@ -{% extends "base/container.html" %} - -{% block content %} -
-
-

Oups erreur {{ error_code }}

-
-
-{% endblock %} From 22814fc1453a207f38ebabce649cc34743c06aea Mon Sep 17 00:00:00 2001 From: Eragonfr Date: Mon, 16 Apr 2018 13:27:05 +0200 Subject: [PATCH 04/13] =?UTF-8?q?404=20plus=20marante=20et=20l'erreur=20da?= =?UTF-8?q?ns=20les=20routes=20est=20corrig=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/routes.py | 4 ++-- app/templates/base/errors.html | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/routes.py b/app/routes.py index 7c7bcb6..06ad4b1 100644 --- a/app/routes.py +++ b/app/routes.py @@ -78,6 +78,6 @@ def errors(error): return redirect(url_for('index')) login_user(user, remember=form.remember_me.data) try: - return render_template("base/errors.html.j2", error_code = error, form=form), error + return render_template("base/errors.html", error_code = error, form=form), error except: - return render_template("base/errors.html.j2", error_code = error.code, form=form), error.code + return render_template("base/errors.html", error_code = error.code, form=form), error.code diff --git a/app/templates/base/errors.html b/app/templates/base/errors.html index 3d77bcd..53f80d1 100644 --- a/app/templates/base/errors.html +++ b/app/templates/base/errors.html @@ -13,6 +13,27 @@ Forbidden : La page vous est interdit. {% elif error_code == 404 %} Not Found : La page n'existe pas ou plus, si vous avez rentré l'url à la main vérifiez de ne pas vous être trompé. +
      /|   /‾‾‾‾‾‾‾\        /|     |\         |   /‾‾‾‾‾\   –––––––––
+     / |  /         \      / |     | \        |  /       \      |
+    /  |  |         |     /  |     |  \       | /         \     |
+   /   |  |         |    /   |     |   \      | |         |     |
+  /    |  |         |   /    |     |    \     | |         |     |
+ /     |  |         |  /     |     |     \    | |         |     |
+/______|_ |         | /______|_    |      \   | |         |     |
+       |  |         |        |     |       \  | \         /     |
+       |  \         /        |     |        \ |  \       /      |
+       |   \_______/         |     |         \|   \_____/       |
+
+|‾‾‾‾‾‾‾‾‾‾   /‾‾‾‾‾\   |         | |\         | |‾‾‾‾‾‾‾\
+|            /       \  |         | | \        | |        \
+|           /         \ |         | |  \       | |         \
+|           |         | |         | |   \      | |         |
+|–––––––    |         | |         | |    \     | |         |
+|           |         | |         | |     \    | |         |
+|           |         | |         | |      \   | |         |
+|           \         / \         / |       \  | |         /
+|            \       /   \       /  |        \ | |        /
+|             \_____/     \_____/   |         \| |_______/
{% elif error_code == 418 %} I’m a teapot : Je suis une théière {% elif error_code == 500 %} From 79257ddf56ef6e993a9e4891ac34d2498f1d024d Mon Sep 17 00:00:00 2001 From: Eragonfr Date: Mon, 16 Apr 2018 18:16:46 +0200 Subject: [PATCH 05/13] rename all .html file to filename.html.j2 --- app/routes.py | 10 +++++----- .../base/{alerts.html => alerts.html.j2} | 0 app/templates/base/base.html | 16 ---------------- app/templates/base/base.html.j2 | 16 ++++++++++++++++ .../base/{container.html => container.html.j2} | 4 ++-- .../base/{errors.html => errors.html.j2} | 2 +- .../base/{footer.html => footer.html.j2} | 0 app/templates/base/{head.html => head.html.j2} | 0 .../base/{header.html => header.html.j2} | 0 .../base/{navbar.html => navbar.html.j2} | 14 +++++++------- .../navbar/{account.html => account.html.j2} | 2 +- .../base/navbar/{forum.html => forum.html.j2} | 0 .../base/navbar/{news.html => news.html.j2} | 0 .../navbar/{programs.html => programs.html.j2} | 0 .../navbar/{sprites.html => sprites.html.j2} | 0 .../base/navbar/{tools.html => tools.html.j2} | 0 .../navbar/{tutorials.html => tutorials.html.j2} | 0 .../base/{scripts.html => scripts.html.j2} | 0 app/templates/{index.html => index.html.j2} | 2 +- app/templates/{login.html => login.html.j2} | 2 +- .../{register.html => register.html.j2} | 2 +- .../{validation.html => validation.html.j2} | 2 +- 22 files changed, 36 insertions(+), 36 deletions(-) rename app/templates/base/{alerts.html => alerts.html.j2} (100%) delete mode 100644 app/templates/base/base.html create mode 100644 app/templates/base/base.html.j2 rename app/templates/base/{container.html => container.html.j2} (63%) rename app/templates/base/{errors.html => errors.html.j2} (98%) rename app/templates/base/{footer.html => footer.html.j2} (100%) rename app/templates/base/{head.html => head.html.j2} (100%) rename app/templates/base/{header.html => header.html.j2} (100%) rename app/templates/base/{navbar.html => navbar.html.j2} (89%) rename app/templates/base/navbar/{account.html => account.html.j2} (99%) rename app/templates/base/navbar/{forum.html => forum.html.j2} (100%) rename app/templates/base/navbar/{news.html => news.html.j2} (100%) rename app/templates/base/navbar/{programs.html => programs.html.j2} (100%) rename app/templates/base/navbar/{sprites.html => sprites.html.j2} (100%) rename app/templates/base/navbar/{tools.html => tools.html.j2} (100%) rename app/templates/base/navbar/{tutorials.html => tutorials.html.j2} (100%) rename app/templates/base/{scripts.html => scripts.html.j2} (100%) rename app/templates/{index.html => index.html.j2} (76%) rename app/templates/{login.html => login.html.j2} (95%) rename app/templates/{register.html => register.html.j2} (96%) rename app/templates/{validation.html => validation.html.j2} (86%) diff --git a/app/routes.py b/app/routes.py index 06ad4b1..7c81258 100644 --- a/app/routes.py +++ b/app/routes.py @@ -17,7 +17,7 @@ def index(): return redirect(url_for('index')) login_user(user, remember=form.remember_me.data) - return render_template('index.html', form=form) + return render_template('index.html.j2', form=form) @app.route('/logout/') @@ -45,7 +45,7 @@ def register(): db.session.commit() flash('Congratulations, you are now a registered user!') return redirect(url_for('validation')) - return render_template('register.html', title='Register', form=form, form2 = form2) + return render_template('register.html.j2', title='Register', form=form, form2 = form2) @app.route('/register/validation/') def validation(): @@ -58,7 +58,7 @@ def validation(): flash('pseudo ou mot de passe invalide') return redirect(url_for('index')) login_user(user, remember=form.remember_me.data) - return render_template('validation.html', form = form) + return render_template('validation.html.j2', form = form) @app.route('/error/') @app.errorhandler(400) @@ -78,6 +78,6 @@ def errors(error): return redirect(url_for('index')) login_user(user, remember=form.remember_me.data) try: - return render_template("base/errors.html", error_code = error, form=form), error + return render_template("base/errors.html.j2", error_code = error, form=form), error except: - return render_template("base/errors.html", error_code = error.code, form=form), error.code + return render_template("base/errors.html.j2", error_code = error.code, form=form), error.code diff --git a/app/templates/base/alerts.html b/app/templates/base/alerts.html.j2 similarity index 100% rename from app/templates/base/alerts.html rename to app/templates/base/alerts.html.j2 diff --git a/app/templates/base/base.html b/app/templates/base/base.html deleted file mode 100644 index fb755d1..0000000 --- a/app/templates/base/base.html +++ /dev/null @@ -1,16 +0,0 @@ - - - {% include "base/head.html" %} - - {% include "base/navbar.html" %} - - {% block container %} - {% endblock container %} - - {% include "base/footer.html" %} - - {% include "base/alerts.html" %} - - {% include "base/scripts.html" %} - - diff --git a/app/templates/base/base.html.j2 b/app/templates/base/base.html.j2 new file mode 100644 index 0000000..2650ee8 --- /dev/null +++ b/app/templates/base/base.html.j2 @@ -0,0 +1,16 @@ + + + {% include "base/head.html.j2" %} + + {% include "base/navbar.html.j2" %} + + {% block container %} + {% endblock container %} + + {% include "base/footer.html.j2" %} + + {% include "base/alerts.html.j2" %} + + {% include "base/scripts.html.j2" %} + + diff --git a/app/templates/base/container.html b/app/templates/base/container.html.j2 similarity index 63% rename from app/templates/base/container.html rename to app/templates/base/container.html.j2 index cf4302e..9cfa4f7 100644 --- a/app/templates/base/container.html +++ b/app/templates/base/container.html.j2 @@ -1,8 +1,8 @@ -{% extends "base/base.html" %} +{% extends "base/base.html.j2" %} {% block container %}
- {% include "base/header.html" %} + {% include "base/header.html.j2" %} {% block content %} {% endblock content %} diff --git a/app/templates/base/errors.html b/app/templates/base/errors.html.j2 similarity index 98% rename from app/templates/base/errors.html rename to app/templates/base/errors.html.j2 index 53f80d1..58ffc6d 100644 --- a/app/templates/base/errors.html +++ b/app/templates/base/errors.html.j2 @@ -1,4 +1,4 @@ -{% extends "base/container.html" %} +{% extends "base/container.html.j2" %} {% block content %}
diff --git a/app/templates/base/footer.html b/app/templates/base/footer.html.j2 similarity index 100% rename from app/templates/base/footer.html rename to app/templates/base/footer.html.j2 diff --git a/app/templates/base/head.html b/app/templates/base/head.html.j2 similarity index 100% rename from app/templates/base/head.html rename to app/templates/base/head.html.j2 diff --git a/app/templates/base/header.html b/app/templates/base/header.html.j2 similarity index 100% rename from app/templates/base/header.html rename to app/templates/base/header.html.j2 diff --git a/app/templates/base/navbar.html b/app/templates/base/navbar.html.j2 similarity index 89% rename from app/templates/base/navbar.html rename to app/templates/base/navbar.html.j2 index bcb2423..967f2b9 100644 --- a/app/templates/base/navbar.html +++ b/app/templates/base/navbar.html.j2 @@ -70,19 +70,19 @@