Add new menu instance for user related links.
This commit is contained in:
@@ -17,6 +17,7 @@ Other changes
|
||||
- Fix height calculation in resize transformation
|
||||
- Improve upgrade instructions
|
||||
- New image caching pipeline
|
||||
- New drop down user menu
|
||||
|
||||
Removals
|
||||
--------
|
||||
|
||||
@@ -68,11 +68,32 @@
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
{% if not request.user.is_authenticated %}
|
||||
{% trans 'Anonymous' %}
|
||||
{% else %}
|
||||
<li><a href="{% url 'common:current_user_details' %}" title="{% trans 'User details' %}">{{ request.user.get_full_name|default:request.user }} <i class="fa fa-user"></i></a></li>
|
||||
{% endif %}
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true">
|
||||
{% if not request.user.is_authenticated %}
|
||||
{% trans 'Anonymous' %}
|
||||
{% else %}
|
||||
{{ request.user.get_full_name|default:request.user }} <i class="fa fa-user"></i>
|
||||
{% endif %}
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
{% get_menu_links 'user menu' as menu_links %}
|
||||
{% for link_set in menu_links %}
|
||||
{% for link in link_set %}
|
||||
{% with 'true' as as_li %}
|
||||
{% with 'true' as hide_active_anchor %}
|
||||
{% with 'first' as li_class_first %}
|
||||
{% with ' ' as link_classes %}
|
||||
{% include 'navigation/generic_subnavigation.html' %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
{% if link.disabled %}
|
||||
<a class="{% if link_classes %}{{ link_classes }} {% else %}btn {% if 'dangerous' in link.tags %}btn-danger{% else %}btn-primary{% endif %} btn-xs{% endif %} {% if 'new_window' in link.tags %}new_window{% endif %} {% if link.active %}{{ link_class_active }}{% endif %}" disabled='disabled' style="cursor: default;" href="#">{% if link.icon %}<i class="hidden-xs hidden-sm {{ link.icon }}"></i> {% endif %}{{ link.text }}{% if link.error %} - {{ link.error }}{% endif %}</a>{% if horizontal %}{% if not forloop.last %} {% endif %}{% endif %}
|
||||
{% if link.separator %}
|
||||
<li role="separator" class="divider"></li>
|
||||
{% else %}
|
||||
<a class="{% if link_classes %}{{ link_classes }} {% else %}btn {% if 'dangerous' in link.tags %}btn-danger{% else %}btn-primary{% endif %} btn-xs{% endif %} {% if link.active %}{{ link_class_active }}{% endif %}" href="{{ link.url }}">{% if link.icon %}<i class="hidden-xs hidden-sm {{ link.icon }}"></i> {% endif %}{{ link.text }}{% if link.error %} - {{ link.error }}{% endif %}</a>{% if horizontal %}{% if not forloop.last %} {% endif %}{% endif %}
|
||||
{% if link.disabled %}
|
||||
<a class="{% if link_classes %}{{ link_classes }} {% else %}btn {% if 'dangerous' in link.tags %}btn-danger{% else %}btn-primary{% endif %} btn-xs{% endif %} {% if 'new_window' in link.tags %}new_window{% endif %} {% if link.active %}{{ link_class_active }}{% endif %}" disabled='disabled' style="cursor: default;" href="#">{% if link.icon %}<i class="hidden-xs hidden-sm {{ link.icon }}"></i> {% endif %}{{ link.text }}{% if link.error %} - {{ link.error }}{% endif %}</a>{% if horizontal %}{% if not forloop.last %} {% endif %}{% endif %}
|
||||
{% else %}
|
||||
<a class="{% if link_classes %}{{ link_classes }} {% else %}btn {% if 'dangerous' in link.tags %}btn-danger{% else %}btn-primary{% endif %} btn-xs{% endif %} {% if link.active %}{{ link_class_active }}{% endif %}" href="{{ link.url }}">{% if link.icon %}<i class="hidden-xs hidden-sm {{ link.icon }}"></i> {% endif %}{{ link.text }}{% if link.error %} - {{ link.error }}{% endif %}</a>{% if horizontal %}{% if not forloop.last %} {% endif %}{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -4,7 +4,7 @@ import logging
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from common import MayanAppConfig, menu_secondary
|
||||
from common import MayanAppConfig, menu_user
|
||||
|
||||
from .links import link_logout, link_password_change
|
||||
|
||||
@@ -19,14 +19,8 @@ class AuthenticationApp(MayanAppConfig):
|
||||
def ready(self):
|
||||
super(AuthenticationApp, self).ready()
|
||||
|
||||
menu_secondary.bind_links(
|
||||
menu_user.bind_links(
|
||||
links=(
|
||||
link_password_change, link_logout
|
||||
), position=99, sources=(
|
||||
'common:current_user_details', 'common:current_user_edit',
|
||||
'common:current_user_locale_profile_details',
|
||||
'common:current_user_locale_profile_edit',
|
||||
'authentication:password_change_view',
|
||||
'common:setup_list', 'common:tools_list'
|
||||
)
|
||||
), position=99
|
||||
)
|
||||
|
||||
@@ -27,7 +27,7 @@ from .links import (
|
||||
link_packages_licenses, link_setup, link_tools
|
||||
)
|
||||
from .literals import DELETE_STALE_UPLOADS_INTERVAL
|
||||
from .menus import menu_facet, menu_main, menu_secondary, menu_tools
|
||||
from .menus import menu_facet, menu_main, menu_tools, menu_user
|
||||
from .settings import setting_auto_logging
|
||||
from .tasks import task_delete_stale_uploads # NOQA - Force task registration
|
||||
|
||||
@@ -1013,20 +1013,15 @@ THE SOFTWARE.
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
menu_facet.bind_links(
|
||||
from navigation.classes import Separator
|
||||
menu_user.bind_links(
|
||||
links=(
|
||||
link_current_user_details,
|
||||
link_current_user_locale_profile_details, link_tools,
|
||||
link_setup
|
||||
), sources=(
|
||||
'common:current_user_details', 'common:current_user_edit',
|
||||
'common:current_user_locale_profile_details',
|
||||
'common:current_user_locale_profile_edit',
|
||||
'authentication:password_change_view', 'common:setup_list',
|
||||
'common:tools_list'
|
||||
link_current_user_details, link_current_user_edit,
|
||||
link_current_user_locale_profile_edit, link_tools, link_setup,
|
||||
Separator()
|
||||
)
|
||||
)
|
||||
|
||||
menu_facet.bind_links(
|
||||
links=(link_about, link_license, link_packages_licenses),
|
||||
sources=(
|
||||
@@ -1035,18 +1030,6 @@ THE SOFTWARE.
|
||||
)
|
||||
)
|
||||
menu_main.bind_links(links=(link_about,), position=99)
|
||||
menu_secondary.bind_links(
|
||||
links=(
|
||||
link_current_user_edit, link_current_user_locale_profile_edit
|
||||
),
|
||||
sources=(
|
||||
'common:current_user_details', 'common:current_user_edit',
|
||||
'common:current_user_locale_profile_details',
|
||||
'common:current_user_locale_profile_edit',
|
||||
'authentication:password_change_view', 'common:setup_list',
|
||||
'common:tools_list'
|
||||
)
|
||||
)
|
||||
|
||||
menu_tools.bind_links(
|
||||
links=(link_filters,)
|
||||
|
||||
@@ -5,7 +5,7 @@ from navigation import Menu
|
||||
__all__ = (
|
||||
'menu_facet', 'menu_front_page', 'menu_object', 'menu_main',
|
||||
'menu_multi_item', 'menu_secondary', 'menu_setup', 'menu_sidebar',
|
||||
'menu_tools'
|
||||
'menu_tools', 'menu_user'
|
||||
)
|
||||
|
||||
menu_facet = Menu(name='object facet')
|
||||
@@ -17,3 +17,4 @@ menu_secondary = Menu(name='secondary menu')
|
||||
menu_setup = Menu(name='setup menu')
|
||||
menu_sidebar = Menu(name='sidebar menu')
|
||||
menu_tools = Menu(name='tools menu')
|
||||
menu_user = Menu(name='user menu')
|
||||
|
||||
@@ -153,7 +153,7 @@ class Menu(object):
|
||||
# No need for further content object match testing
|
||||
break
|
||||
elif hasattr(resolved_navigation_object, 'get_deferred_fields') and resolved_navigation_object.get_deferred_fields() and isinstance(resolved_navigation_object, bound_source):
|
||||
# Second try for objects using .defer() or .only()
|
||||
# Second try for objects using .defer() or .only()
|
||||
for link in links:
|
||||
resolved_link = link.resolve(
|
||||
context=context,
|
||||
@@ -362,6 +362,21 @@ class Link(object):
|
||||
return resolved_link
|
||||
|
||||
|
||||
class Separator(Link):
|
||||
def __init__(self, text=None, view=None, args=None, condition=None,
|
||||
conditional_disable=None, description=None, icon=None,
|
||||
keep_query=False, kwargs=None, permissions=None,
|
||||
permissions_related=None, remove_from_query=None, tags=None):
|
||||
self.icon = None
|
||||
self.text = None
|
||||
self.view = None
|
||||
|
||||
def resolve(self, context, resolved_object=None):
|
||||
result = ResolvedLink(current_view=None, link=self)
|
||||
result.separator = True
|
||||
return result
|
||||
|
||||
|
||||
class SourceColumn(object):
|
||||
_registry = {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user