Switch from macros to blocks for navigation menus
This affects the user and notifications menus. It happens for two reasons: - the only argument passed to the macros was current_user, which is always available - we want to enable overriding and adding items to the menus via extensions At the moment only the user menu takes advantage of the base template, since the blender-cloud extension makes use of it, while notifications.pug does not need it yet.
This commit is contained in:
parent
20ca3f8ee4
commit
a7693aa78d
@ -1,142 +0,0 @@
|
|||||||
| {% macro navigation_menu_user(current_user) %}
|
|
||||||
|
|
||||||
| {% if current_user.is_authenticated %}
|
|
||||||
|
|
||||||
| {% if current_user.has_role('demo') %}
|
|
||||||
| {% set subscription = 'demo' %}
|
|
||||||
| {% elif current_user.has_cap('subscriber') %}
|
|
||||||
| {% set subscription = 'subscriber' %}
|
|
||||||
| {% else %}
|
|
||||||
| {% set subscription = 'none' %}
|
|
||||||
| {% endif %}
|
|
||||||
|
|
||||||
li(class="dropdown")
|
|
||||||
a.navbar-item.dropdown-toggle(href="#", data-toggle="dropdown", title="{{ current_user.email }}")
|
|
||||||
img.gravatar(
|
|
||||||
src="{{ current_user.gravatar }}",
|
|
||||||
class="{{ subscription }}",
|
|
||||||
alt="Avatar")
|
|
||||||
.special(class="{{ subscription }}")
|
|
||||||
| {% if subscription == 'subscriber' %}
|
|
||||||
i.pi-check
|
|
||||||
| {% elif subscription == 'demo' %}
|
|
||||||
i.pi-heart-filled
|
|
||||||
| {% else %}
|
|
||||||
i.pi-attention
|
|
||||||
| {% endif %}
|
|
||||||
|
|
||||||
ul.dropdown-menu
|
|
||||||
| {% if not current_user.has_role('protected') %}
|
|
||||||
li.subscription-status(class="{{ subscription }}")
|
|
||||||
| {% if subscription == 'subscriber' %}
|
|
||||||
a.navbar-item(
|
|
||||||
href="{{url_for('settings.billing')}}"
|
|
||||||
title="View subscription info")
|
|
||||||
i.pi-grin
|
|
||||||
span Your subscription is active!
|
|
||||||
| {% elif subscription == 'demo' %}
|
|
||||||
a.navbar-item(
|
|
||||||
href="{{url_for('settings.billing')}}"
|
|
||||||
title="View subscription info")
|
|
||||||
i.pi-heart-filled
|
|
||||||
span You have a free account.
|
|
||||||
| {% elif current_user.has_cap('can-renew-subscription') %}
|
|
||||||
a.navbar-item(target='_blank', href="/renew", title="Renew subscription")
|
|
||||||
i.pi-heart
|
|
||||||
span.info Your subscription is not active.
|
|
||||||
span.renew Click here to renew.
|
|
||||||
| {% else %}
|
|
||||||
a.navbar-item(
|
|
||||||
href="https://store.blender.org/product/membership/"
|
|
||||||
title="Renew subscription")
|
|
||||||
i.pi-unhappy
|
|
||||||
span.info Your subscription is not active.
|
|
||||||
span.renew Click here to renew.
|
|
||||||
| {% endif %}
|
|
||||||
|
|
||||||
li
|
|
||||||
a.navbar-item(
|
|
||||||
href="{{ url_for('projects.home_project') }}"
|
|
||||||
title="Home")
|
|
||||||
i.pi-home
|
|
||||||
| Home
|
|
||||||
|
|
||||||
li
|
|
||||||
a.navbar-item(
|
|
||||||
href="{{ url_for('projects.index') }}"
|
|
||||||
title="My Projects")
|
|
||||||
i.pi-star
|
|
||||||
| My Projects
|
|
||||||
|
|
||||||
| {% if current_user.has_organizations() %}
|
|
||||||
li
|
|
||||||
a.navbar-item(
|
|
||||||
href="{{ url_for('pillar.web.organizations.index') }}"
|
|
||||||
title="My Organizations")
|
|
||||||
i.pi-users
|
|
||||||
| My Organizations
|
|
||||||
| {% endif %}
|
|
||||||
|
|
||||||
li
|
|
||||||
a.navbar-item(
|
|
||||||
href="{{ url_for('settings.profile') }}"
|
|
||||||
title="Settings")
|
|
||||||
i.pi-cog
|
|
||||||
| Settings
|
|
||||||
|
|
||||||
li
|
|
||||||
a.navbar-item(
|
|
||||||
href="{{ url_for('settings.billing') }}"
|
|
||||||
title="Billing")
|
|
||||||
i.pi-credit-card
|
|
||||||
| Subscription
|
|
||||||
|
|
||||||
li.divider(role="separator")
|
|
||||||
| {% endif %}
|
|
||||||
|
|
||||||
li
|
|
||||||
a.navbar-item(
|
|
||||||
href="{{ url_for('users.logout') }}")
|
|
||||||
i.pi-log-out(title="Log Out")
|
|
||||||
| Log out
|
|
||||||
a.navbar-item.subitem(
|
|
||||||
href="{{ url_for('users.switch') }}")
|
|
||||||
i.pi-blank
|
|
||||||
| Not {{ current_user.full_name }}?
|
|
||||||
|
|
||||||
| {% else %}
|
|
||||||
|
|
||||||
li.nav-item-sign-in
|
|
||||||
a.navbar-item(href="{{ url_for('users.login') }}")
|
|
||||||
| Log in
|
|
||||||
| {% endif %}
|
|
||||||
|
|
||||||
| {% endmacro %}
|
|
||||||
|
|
||||||
|
|
||||||
| {% macro navigation_menu_notifications(current_user) %}
|
|
||||||
|
|
||||||
| {% if current_user.is_authenticated %}
|
|
||||||
|
|
||||||
li.nav-notifications
|
|
||||||
a.navbar-item#notifications-toggle(
|
|
||||||
title="Notifications",
|
|
||||||
data-toggle="tooltip",
|
|
||||||
data-placement="bottom")
|
|
||||||
i.pi-notifications-none.nav-notifications-icon
|
|
||||||
span#notifications-count
|
|
||||||
span
|
|
||||||
.flyout-hat
|
|
||||||
|
|
||||||
#notifications.flyout.notifications
|
|
||||||
.flyout-content
|
|
||||||
span.flyout-title Notifications
|
|
||||||
a#notifications-markallread(
|
|
||||||
title="Mark All as Read",
|
|
||||||
href="/notifications/read-all")
|
|
||||||
| Mark All as Read
|
|
||||||
|
|
||||||
| {% include '_notifications.html' %}
|
|
||||||
|
|
||||||
| {% endif %}
|
|
||||||
| {% endmacro %}
|
|
23
src/templates/menus/notifications.pug
Normal file
23
src/templates/menus/notifications.pug
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
| {% if current_user.is_authenticated %}
|
||||||
|
|
||||||
|
li.nav-notifications
|
||||||
|
a.navbar-item#notifications-toggle(
|
||||||
|
title="Notifications",
|
||||||
|
data-toggle="tooltip",
|
||||||
|
data-placement="bottom")
|
||||||
|
i.pi-notifications-none.nav-notifications-icon
|
||||||
|
span#notifications-count
|
||||||
|
span
|
||||||
|
.flyout-hat
|
||||||
|
|
||||||
|
#notifications.flyout.notifications
|
||||||
|
.flyout-content
|
||||||
|
span.flyout-title Notifications
|
||||||
|
a#notifications-markallread(
|
||||||
|
title="Mark All as Read",
|
||||||
|
href="/notifications/read-all")
|
||||||
|
| Mark All as Read
|
||||||
|
|
||||||
|
| {% include '_notifications.html' %}
|
||||||
|
|
||||||
|
| {% endif %}
|
1
src/templates/menus/user.pug
Normal file
1
src/templates/menus/user.pug
Normal file
@ -0,0 +1 @@
|
|||||||
|
| {% extends 'menus/user_base.html' %}
|
66
src/templates/menus/user_base.pug
Normal file
66
src/templates/menus/user_base.pug
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
| {% block menu_body %}
|
||||||
|
| {% if current_user.is_authenticated %}
|
||||||
|
|
||||||
|
li(class="dropdown")
|
||||||
|
| {% block menu_avatar %}
|
||||||
|
a.navbar-item.dropdown-toggle(href="#", data-toggle="dropdown", title="{{ current_user.email }}")
|
||||||
|
img.gravatar(
|
||||||
|
src="{{ current_user.gravatar }}",
|
||||||
|
alt="Avatar")
|
||||||
|
| {% endblock menu_avatar %}
|
||||||
|
|
||||||
|
ul.dropdown-menu
|
||||||
|
| {% if not current_user.has_role('protected') %}
|
||||||
|
| {% block menu_list %}
|
||||||
|
li
|
||||||
|
a.navbar-item(
|
||||||
|
href="{{ url_for('projects.home_project') }}"
|
||||||
|
title="Home")
|
||||||
|
i.pi-home
|
||||||
|
| Home
|
||||||
|
|
||||||
|
li
|
||||||
|
a.navbar-item(
|
||||||
|
href="{{ url_for('projects.index') }}"
|
||||||
|
title="My Projects")
|
||||||
|
i.pi-star
|
||||||
|
| My Projects
|
||||||
|
|
||||||
|
| {% if current_user.has_organizations() %}
|
||||||
|
li
|
||||||
|
a.navbar-item(
|
||||||
|
href="{{ url_for('pillar.web.organizations.index') }}"
|
||||||
|
title="My Organizations")
|
||||||
|
i.pi-users
|
||||||
|
| My Organizations
|
||||||
|
| {% endif %}
|
||||||
|
|
||||||
|
li
|
||||||
|
a.navbar-item(
|
||||||
|
href="{{ url_for('settings.profile') }}"
|
||||||
|
title="Settings")
|
||||||
|
i.pi-cog
|
||||||
|
| Settings
|
||||||
|
|
||||||
|
| {% endblock menu_list %}
|
||||||
|
|
||||||
|
li.divider(role="separator")
|
||||||
|
| {% endif %}
|
||||||
|
|
||||||
|
li
|
||||||
|
a.navbar-item(
|
||||||
|
href="{{ url_for('users.logout') }}")
|
||||||
|
i.pi-log-out(title="Log Out")
|
||||||
|
| Log out
|
||||||
|
a.navbar-item.subitem(
|
||||||
|
href="{{ url_for('users.switch') }}")
|
||||||
|
i.pi-blank
|
||||||
|
| Not {{ current_user.full_name }}?
|
||||||
|
|
||||||
|
| {% else %}
|
||||||
|
|
||||||
|
li.nav-item-sign-in
|
||||||
|
a.navbar-item(href="{{ url_for('users.login') }}")
|
||||||
|
| Log in
|
||||||
|
| {% endif %}
|
||||||
|
| {% endblock menu_body %}
|
Loading…
x
Reference in New Issue
Block a user