From d4a95ddb8bfc26d2ffef23da007269eae5098394 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Thu, 10 Nov 2016 23:31:53 -0400 Subject: [PATCH] Add new menu instance for user related links. --- docs/releases/2.2.rst | 1 + .../appearance/templates/appearance/base.html | 31 ++++++++++++++++--- .../navigation/generic_link_instance.html | 10 ++++-- mayan/apps/authentication/apps.py | 12 ++----- mayan/apps/common/apps.py | 31 +++++-------------- mayan/apps/common/menus.py | 3 +- mayan/apps/navigation/classes.py | 17 +++++++++- 7 files changed, 62 insertions(+), 43 deletions(-) diff --git a/docs/releases/2.2.rst b/docs/releases/2.2.rst index cff2a358e0..3f1b5f291e 100644 --- a/docs/releases/2.2.rst +++ b/docs/releases/2.2.rst @@ -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 -------- diff --git a/mayan/apps/appearance/templates/appearance/base.html b/mayan/apps/appearance/templates/appearance/base.html index ad81f8e801..e676b163af 100644 --- a/mayan/apps/appearance/templates/appearance/base.html +++ b/mayan/apps/appearance/templates/appearance/base.html @@ -68,11 +68,32 @@ {% endfor %} diff --git a/mayan/apps/appearance/templates/navigation/generic_link_instance.html b/mayan/apps/appearance/templates/navigation/generic_link_instance.html index f2d57259cd..f35dbd6e98 100644 --- a/mayan/apps/appearance/templates/navigation/generic_link_instance.html +++ b/mayan/apps/appearance/templates/navigation/generic_link_instance.html @@ -1,5 +1,9 @@ -{% if link.disabled %} - {% if link.icon %} {% endif %}{{ link.text }}{% if link.error %} - {{ link.error }}{% endif %}{% if horizontal %}{% if not forloop.last %} {% endif %}{% endif %} +{% if link.separator %} + {% else %} - {% if link.icon %} {% endif %}{{ link.text }}{% if link.error %} - {{ link.error }}{% endif %}{% if horizontal %}{% if not forloop.last %} {% endif %}{% endif %} + {% if link.disabled %} + {% if link.icon %} {% endif %}{{ link.text }}{% if link.error %} - {{ link.error }}{% endif %}{% if horizontal %}{% if not forloop.last %} {% endif %}{% endif %} + {% else %} + {% if link.icon %} {% endif %}{{ link.text }}{% if link.error %} - {{ link.error }}{% endif %}{% if horizontal %}{% if not forloop.last %} {% endif %}{% endif %} + {% endif %} {% endif %} diff --git a/mayan/apps/authentication/apps.py b/mayan/apps/authentication/apps.py index dd63d47de9..85942e587c 100644 --- a/mayan/apps/authentication/apps.py +++ b/mayan/apps/authentication/apps.py @@ -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 ) diff --git a/mayan/apps/common/apps.py b/mayan/apps/common/apps.py index 793a204d80..ecbd535d24 100644 --- a/mayan/apps/common/apps.py +++ b/mayan/apps/common/apps.py @@ -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,) diff --git a/mayan/apps/common/menus.py b/mayan/apps/common/menus.py index b1004b952c..382fd7f4d2 100644 --- a/mayan/apps/common/menus.py +++ b/mayan/apps/common/menus.py @@ -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') diff --git a/mayan/apps/navigation/classes.py b/mayan/apps/navigation/classes.py index 58cc553e85..0104ed15c8 100644 --- a/mayan/apps/navigation/classes.py +++ b/mayan/apps/navigation/classes.py @@ -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 = {}