Improved flash messages display on the homepage

This commit is contained in:
Éloi Rivard 2022-12-28 00:45:34 +01:00
parent f89d45a3e7
commit b0534896b5
4 changed files with 90 additions and 74 deletions

View file

@ -1,7 +1,7 @@
{% macro messages() %} {% macro messages() %}
{% with messages = get_flashed_messages(with_categories=true) %} {% with messages = get_flashed_messages(with_categories=true) %}
{% for category, message in messages %} {% for category, message in messages %}
<div class="ui attached message {{ category }}"> <div class="ui message {{ category }}">
{{ message }} {{ message }}
</div> </div>
{% endfor %} {% endfor %}

View file

@ -1,45 +1,52 @@
{% extends theme('base.html') %} {% extends theme('base.html') %}
{% import 'flask.j2' as flask %}
{% import 'fomanticui.html' as sui %} {% import 'fomanticui.html' as sui %}
{% block content %} {% block container %}
<div class="ui clearing segment"> <div class="ui container">
{% if logo_url %} <div class="content">
<a href="{{ url_for('account.index') }}"> <div class="ui clearing segment">
<img class="ui tiny centered image" src="{{ logo_url }}" alt="{{ website_name }}"> {% if logo_url %}
</a> <a href="{{ url_for('account.index') }}">
{% else %} <img class="ui tiny centered image" src="{{ logo_url }}" alt="{{ website_name }}">
<i class="massive sign in icon image ui"></i> </a>
{% endif %} {% else %}
<i class="massive sign in icon image ui"></i>
{% endif %}
<h2 class="ui center aligned header"> <h2 class="ui center aligned header">
<div class="content"> <div class="content">
{{ _("Sign in at %(website)s", website=website_name) }} {{ _("Sign in at %(website)s", website=website_name) }}
</div> </div>
<div class="sub header">{% trans %}Log-in and manage your authorizations.{% endtrans %}</div> <div class="sub header">{% trans %}Log-in and manage your authorizations.{% endtrans %}</div>
</h2> </h2>
<form method="POST" {{ flask.messages() }}
id="{{ form.id or form.__class__.__name__|lower }}"
action="{{ request.url }}"
role="form"
class="ui form"
>
{{ form.hidden_tag() if form.hidden_tag }} <form method="POST"
{% block login_field scoped %}{{ sui.render_field(form.login, icon="user", noindicator=true) }}{% endblock %} id="{{ form.id or form.__class__.__name__|lower }}"
action="{{ request.url }}"
role="form"
class="ui form"
>
{% if "password" in form %} {{ form.hidden_tag() if form.hidden_tag }}
{% block password_field scoped %}{{ sui.render_field(form.password, icon="key", noindicator=true) }}{% endblock %} {% block login_field scoped %}{{ sui.render_field(form.login, icon="user", noindicator=true) }}{% endblock %}
{% endif %}
<div class="ui right aligned container"> {% if "password" in form %}
<div class="ui stackable buttons"> {% block password_field scoped %}{{ sui.render_field(form.password, icon="key", noindicator=true) }}{% endblock %}
{% if has_smtp and has_password_recovery %}
<a type="button" class="ui right floated button" href="{{ url_for('account.forgotten') }}">{{ _("Forgotten password") }}</a>
{% endif %} {% endif %}
<button type="submit" class="ui right floated primary button">{{ _("Continue") }}</button>
</div> <div class="ui right aligned container">
<div class="ui stackable buttons">
{% if has_smtp and has_password_recovery %}
<a type="button" class="ui right floated button" href="{{ url_for('account.forgotten') }}">{{ _("Forgotten password") }}</a>
{% endif %}
<button type="submit" class="ui right floated primary button">{{ _("Continue") }}</button>
</div>
</div>
</form>
</div> </div>
</form> </div>
</div> </div>
{% endblock %} {% endblock %}

View file

@ -1,42 +1,49 @@
{% extends theme('base.html') %} {% extends theme('base.html') %}
{% import 'flask.j2' as flask %}
{% import 'fomanticui.html' as sui %} {% import 'fomanticui.html' as sui %}
{% block content %} {% block container %}
<div class="ui clearing segment"> <div class="ui container">
{% if logo_url %} <div class="content">
<a href="{{ url_for('account.index') }}"> <div class="ui clearing segment">
<img class="ui tiny centered image" src="{{ logo_url }}" alt="{{ website_name }}"> {% if logo_url %}
</a> <a href="{{ url_for('account.index') }}">
{% else %} <img class="ui tiny centered image" src="{{ logo_url }}" alt="{{ website_name }}">
<i class="massive sign in icon image ui"></i> </a>
{% endif %} {% else %}
<i class="massive sign in icon image ui"></i>
{% endif %}
<h2 class="ui center aligned header"> <h2 class="ui center aligned header">
<div class="content"> <div class="content">
{{ _("Sign in as %(username)s", username=username) }} {{ _("Sign in as %(username)s", username=username) }}
</div>
<div class="sub header">{% trans %}Please enter your password for this account.{% endtrans %}</div>
</h2>
{{ flask.messages() }}
<form method="POST"
id="{{ form.id or form.__class__.__name__|lower }}"
action="{{ request.url }}"
role="form"
class="ui form"
>
{{ form.hidden_tag() if form.hidden_tag }}
{{ sui.render_field(form.password, icon="key", noindicator=true) }}
<div class="ui right aligned container">
<div class="ui stackable buttons">
<a type="button" class="ui right floated button" href="{{ url_for('account.login') }}">{{ _("I am not %(username)s", username=username) }}</a>
{% if has_smtp and has_password_recovery %}
<a type="button" class="ui right floated button" href="{{ url_for('account.forgotten') }}">{{ _("Forgotten password") }}</a>
{% endif %}
<button type="submit" class="ui right floated primary button">{{ _("Sign in") }}</button>
</div>
</div>
</form>
</div> </div>
<div class="sub header">{% trans %}Please enter your password for this account.{% endtrans %}</div> </div>
</h2>
<form method="POST"
id="{{ form.id or form.__class__.__name__|lower }}"
action="{{ request.url }}"
role="form"
class="ui form"
>
{{ form.hidden_tag() if form.hidden_tag }}
{{ sui.render_field(form.password, icon="key", noindicator=true) }}
<div class="ui right aligned container">
<div class="ui stackable buttons">
<a type="button" class="ui right floated button" href="{{ url_for('account.login') }}">{{ _("I am not %(username)s", username=username) }}</a>
{% if has_smtp and has_password_recovery %}
<a type="button" class="ui right floated button" href="{{ url_for('account.forgotten') }}">{{ _("Forgotten password") }}</a>
{% endif %}
<button type="submit" class="ui right floated primary button">{{ _("Sign in") }}</button>
</div>
</div>
</form>
</div> </div>
{% endblock %} {% endblock %}

View file

@ -93,12 +93,14 @@
{% endif %} {% endif %}
{% endblock %} {% endblock %}
<div class="ui container"> {% block container %}
<div class="content"> <div class="ui container">
{{ flask.messages() }} <div class="content">
{% block content %}{% endblock %} {{ flask.messages() }}
{% block content %}{% endblock %}
</div>
</div> </div>
</div> {% endblock %}
<footer> <footer>
<a href="{{ url_for('account.about') }}">{{ _("About canaille") }}</a> <a href="{{ url_for('account.about') }}">{{ _("About canaille") }}</a>