From de07f6f31cce78a9adf75410890908257956a4bb Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Fri, 18 Jul 2014 18:44:28 -0400 Subject: [PATCH] Move common app links to a separate module --- mayan/apps/common/__init__.py | 23 +++++++---------------- mayan/apps/common/links.py | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 16 deletions(-) create mode 100644 mayan/apps/common/links.py diff --git a/mayan/apps/common/__init__.py b/mayan/apps/common/__init__.py index b9eb49a8b7..57625f1b9c 100644 --- a/mayan/apps/common/__init__.py +++ b/mayan/apps/common/__init__.py @@ -15,25 +15,16 @@ from south.signals import post_migrate from navigation.api import register_links, register_top_menu from .conf import settings as common_settings -from .conf.settings import (AUTO_CREATE_ADMIN, AUTO_ADMIN_USERNAME, - AUTO_ADMIN_PASSWORD, TEMPORARY_DIRECTORY) +from .conf.settings import (AUTO_ADMIN_USERNAME, AUTO_ADMIN_PASSWORD, + AUTO_CREATE_ADMIN, TEMPORARY_DIRECTORY) +from .links import (link_about, link_current_user_details, + link_current_user_edit, link_license, + link_password_change) from .models import AutoAdminSingleton from .utils import validate_path - -def has_usable_password(context): - return context['request'].user.has_usable_password - -password_change_view = {'text': _(u'change password'), 'view': 'password_change_view', 'famfam': 'computer_key', 'condition': has_usable_password} -current_user_details = {'text': _(u'user details'), 'view': 'current_user_details', 'famfam': 'vcard'} -current_user_edit = {'text': _(u'edit details'), 'view': 'current_user_edit', 'famfam': 'vcard_edit'} - -register_links(['current_user_details', 'current_user_edit', 'password_change_view'], [current_user_details, current_user_edit, password_change_view], menu_name='secondary_menu') - -about_view = {'text': _('about'), 'view': 'about_view', 'famfam': 'information'} -license_view = {'text': _('license'), 'view': 'license_view', 'famfam': 'script'} - -register_links(['about_view', 'license_view'], [about_view, license_view], menu_name='secondary_menu') +register_links(['current_user_details', 'current_user_edit', 'password_change_view'], [link_current_user_details, link_current_user_edit, link_password_change], menu_name='secondary_menu') +register_links(['about_view', 'license_view', 'form_view'], [link_about, link_license], menu_name='secondary_menu') register_top_menu('about', link={'text': _(u'about'), 'view': 'about_view', 'famfam': 'information'}, position=-1) diff --git a/mayan/apps/common/links.py b/mayan/apps/common/links.py new file mode 100644 index 0000000000..0a32ab472e --- /dev/null +++ b/mayan/apps/common/links.py @@ -0,0 +1,15 @@ +from __future__ import absolute_import + +from django.utils.translation import ugettext_lazy as _ + + +def has_usable_password(context): + return context['request'].user.has_usable_password + + +link_password_change = {'text': _(u'change password'), 'view': 'password_change_view', 'famfam': 'computer_key', 'condition': has_usable_password} +link_current_user_details = {'text': _(u'user details'), 'view': 'current_user_details', 'famfam': 'vcard'} +link_current_user_edit = {'text': _(u'edit details'), 'view': 'current_user_edit', 'famfam': 'vcard_edit'} + +link_about = {'text': _('about'), 'view': 'about_view', 'famfam': 'information'} +link_license = {'text': _('license'), 'view': 'license_view', 'famfam': 'script'}