Use Jinja2 inheritance to render settings pages.

This gives us more flexibility than using {% include %}.
This commit is contained in:
Sybren A. Stüvel 2018-01-25 12:25:32 +01:00
parent fd3e795824
commit 0a0c47205f
4 changed files with 59 additions and 47 deletions

View File

@ -1,10 +0,0 @@
#settings-sidebar
.settings-header
.settings-title Settings
.settings-content
ul
a(class="{% if title == 'profile' %}active{% endif %}",
href="{{ url_for('settings.profile') }}")
li
i.pi-vcard
| Profile

View File

@ -0,0 +1,29 @@
| {% extends 'layout.html' %}
//- Don't extend this base file directly. Instead, extend page.html so that Pillar extensions
//- can provide overrides.
| {% block body %}
.container
#settings
#settings-sidebar
| {% block settings_sidebar %}
.settings-header
.settings-title Settings
.settings-content
ul
| {% block settings_sidebar_menu %}
a(class="{% if title == 'profile' %}active{% endif %}",
href="{{ url_for('settings.profile') }}")
li
i.pi-vcard
| Profile
| {% endblock settings_sidebar_menu %}
| {% endblock %}
#settings-container
.settings-header
.settings-title {% block settings_page_title %}{{ _("Title not set") }}{% endblock %}
.settings-content
| {% block settings_page_content %}No content set, update your template.{% endblock %}
| {% endblock %}

View File

@ -0,0 +1 @@
| {% extends 'users/settings/base.html' %}

View File

@ -1,42 +1,34 @@
| {% extends 'layout.html' %} | {% extends 'users/settings/page.html' %}
| {% block body %} | {% block settings_page_title %}{{ _("Profile") }}{% endblock %}
.container | {% block settings_page_content %}
#settings .settings-form
| {% include 'users/settings/_sidebar.html'%} form#settings-form(method='POST', action="{{url_for('settings.profile')}}")
#settings-container .left
.settings-header .form-group
.settings-title {{ _("Profile") }} | {{ form.username.label }}
| {{ form.username(size=20, class='form-control') }}
| {% if form.username.errors %}
| {% for error in form.username.errors %}{{ error|e }}{% endfor %}
| {% endif %}
.settings-content .form-group
.settings-form label {{ _("Full name") }}
form#settings-form(method='POST', action="{{url_for('settings.profile')}}") p {{ current_user.full_name }}
.left .form-group
.form-group label {{ _("E-mail") }}
| {{ form.username.label }} p {{ current_user.email }}
| {{ form.username(size=20, class='form-control') }}
| {% if form.username.errors %}
| {% for error in form.username.errors %}{{ error|e }}{% endfor %}
| {% endif %}
.form-group .form-group
label {{ _("Full name") }} | {{ _("Change your full name, email, and password at") }} #[a(href="https://www.blender.org/id/settings/profile",target='_blank') Blender ID].
p {{ current_user.full_name }}
.form-group
label {{ _("E-mail") }}
p {{ current_user.email }}
.form-group .right
| {{ _("Change your full name, email, and password at") }} #[a(href="https://www.blender.org/id/settings/profile",target='_blank') Blender ID]. .settings-avatar
a(href="https://gravatar.com/")
.right img(src="{{ current_user.gravatar }}")
.settings-avatar span {{ _("Change Gravatar") }}
a(href="https://gravatar.com/")
img(src="{{ current_user.gravatar }}")
span {{ _("Change Gravatar") }}
.buttons
button.btn.btn-default.button-submit(type='submit')
i.pi-check
| {{ _("Save Changes") }}
.buttons
button.btn.btn-default.button-submit(type='submit')
i.pi-check
| {{ _("Save Changes") }}
| {% endblock %} | {% endblock %}