From 2d6e1ff76f59058d6d756f0ca0e9d9bd5344f567 Mon Sep 17 00:00:00 2001 From: kaiyou <pierre@jaury.eu> Date: Sat, 14 Sep 2019 20:32:41 +0200 Subject: [PATCH] Have a generic form template --- trurt/account/login.py | 8 +++++--- trurt/account/settings.py | 8 ++++++-- trurt/account/templates/account_signup.html | 8 -------- trurt/templates/base.html | 4 ++-- .../templates/account_signin.html => templates/form.html} | 3 --- 5 files changed, 13 insertions(+), 18 deletions(-) delete mode 100644 trurt/account/templates/account_signup.html rename trurt/{account/templates/account_signin.html => templates/form.html} (53%) diff --git a/trurt/account/login.py b/trurt/account/login.py index 4a631f4..29254a8 100644 --- a/trurt/account/login.py +++ b/trurt/account/login.py @@ -15,8 +15,9 @@ def signin(): return flask.redirect(utils.url_or_intent(".home")) else: flask.flash("Wrong credentials", "danger") - return flask.render_template("account_signin.html", - action=utils.url_for(".signin"), form=form) + return flask.render_template("form.html", form=form, + title="Sign in", subtitle="to access your account", + action=utils.url_for(".signin")) @blueprint.route("/signout") @@ -45,4 +46,5 @@ def signup(): models.db.session.commit() flask.flash("User created successfully", "success") return flask.redirect(utils.url_or_intent("account.home")) - return flask.render_template("account_signup.html", form=form) + return flask.render_template("form.html", form=form, + title="Signup up", subtitle="for a new account") diff --git a/trurt/account/settings.py b/trurt/account/settings.py index 7beae73..5888e54 100644 --- a/trurt/account/settings.py +++ b/trurt/account/settings.py @@ -1,4 +1,4 @@ -from trurt.account import blueprint +from trurt.account import blueprint, forms import flask_login import flask @@ -14,4 +14,8 @@ def home(): @blueprint.route("/password") @flask_login.login_required def password(): - return flask.render_template("account_password.html") + form = forms.PasswordForm() + if form.validate_on_submit(): + pass + return flask.render_template("form.html", form=form, + title="New password") diff --git a/trurt/account/templates/account_signup.html b/trurt/account/templates/account_signup.html deleted file mode 100644 index 2568487..0000000 --- a/trurt/account/templates/account_signup.html +++ /dev/null @@ -1,8 +0,0 @@ -{% extends "base.html" %} - -{% block title %}Sign up{% endblock %} -{% block subtitle %}create a new account{% endblock %} - -{% block content %} -{{ macros.form(form) }} -{% endblock %} diff --git a/trurt/templates/base.html b/trurt/templates/base.html index a5718e3..946265f 100644 --- a/trurt/templates/base.html +++ b/trurt/templates/base.html @@ -58,8 +58,8 @@ <div class="content-wrapper"> <section class="content-header"> <h1> - {% block title %}{% endblock %} - <small>{% block subtitle %}{% endblock %}</small> + {% block title %}{{ title }}{% endblock %} + <small>{% block subtitle %}{{ subtitle }}{% endblock %}</small> </h1> </section> <section class="content container-fluid"> diff --git a/trurt/account/templates/account_signin.html b/trurt/templates/form.html similarity index 53% rename from trurt/account/templates/account_signin.html rename to trurt/templates/form.html index a1624ed..fc7dae6 100644 --- a/trurt/account/templates/account_signin.html +++ b/trurt/templates/form.html @@ -1,8 +1,5 @@ {% extends "base.html" %} -{% block title %}Log in{% endblock %} -{% block subtitle %}{% endblock %} - {% block content %} {{ macros.form(form) }} {% endblock %} -- GitLab