Initial commit of the new class based and menu based navigation system

This commit is contained in:
Roberto Rosario
2015-04-03 07:09:51 -04:00
parent 192069462f
commit 0246068cd0
27 changed files with 399 additions and 485 deletions

View File

@@ -12,7 +12,7 @@ from django.db.models.signals import post_migrate, post_save
from django.utils.translation import ugettext_lazy as _
from common import settings as common_settings
from navigation.api import register_links, register_top_menu
from navigation.api import register_links
from .links import (
link_about, link_current_user_details, link_current_user_edit,
@@ -20,6 +20,7 @@ from .links import (
link_current_user_locale_profile_edit, link_license, link_logout,
link_password_change
)
from .menus import menu_main, menu_secondary
from .models import (
AnonymousUserSingleton, AutoAdminSingleton, UserLocaleProfile
)
@@ -93,10 +94,11 @@ class CommonApp(apps.AppConfig):
verbose_name = _('Common')
def ready(self):
register_links(['common:current_user_details', 'common:current_user_edit', 'common:current_user_locale_profile_details', 'common:current_user_locale_profile_edit', 'common:password_change_view'], [link_current_user_details, link_current_user_edit, link_current_user_locale_profile_details, link_current_user_locale_profile_edit, link_password_change, link_logout], menu_name='secondary_menu')
register_links(['common:about_view', 'common:license_view'], [link_about, link_license], menu_name='secondary_menu')
menu_main.bind_links(links=[link_about], position=-1)
menu_secondary.bind_links(links=[link_about, link_license], sources=['common:about_view', 'common:license_view'])
register_top_menu('about', link_about, position=-1)
register_links(['common:current_user_details', 'common:current_user_edit', 'common:current_user_locale_profile_details', 'common:current_user_locale_profile_edit', 'common:password_change_view'], [link_current_user_details, link_current_user_edit, link_current_user_locale_profile_details, link_current_user_locale_profile_edit, link_password_change, link_logout], menu_name='secondary_menu')
#register_links(['common:about_view', 'common:license_view'], [link_about, link_license], menu_name='secondary_menu')
post_migrate.connect(create_superuser_and_anonymous_user, dispatch_uid='create_superuser_and_anonymous_user')
post_save.connect(auto_admin_account_passwd_change, dispatch_uid='auto_admin_account_passwd_change', sender=User)

View File

@@ -2,18 +2,19 @@ from __future__ import unicode_literals
from django.utils.translation import ugettext_lazy as _
from navigation import Link
def has_usable_password(context):
return context['request'].user.has_usable_password
link_about = Link(icon='fa fa-question', text=_('About'), view='common:about_view')
link_license = Link(icon='fa fa-book', text=_('License'), view='common:license_view')
link_password_change = {'text': _('Change password'), 'view': 'common:password_change_view', 'icon': 'fa fa-key', 'condition': has_usable_password}
link_current_user_details = {'text': _('User details'), 'view': 'common:current_user_details', 'icon': 'fa fa-user'}
link_current_user_edit = {'text': _('Edit details'), 'view': 'common:current_user_edit', 'icon': 'fa fa-user'}
link_about = {'text': _('About'), 'view': 'common:about_view', 'icon': 'fa fa-question'}
link_license = {'text': _('License'), 'view': 'common:license_view', 'icon': 'fa fa-book'}
link_current_user_locale_profile_details = {'text': _('Locale profile'), 'view': 'common:current_user_locale_profile_details', 'icon': 'fa fa-globe'}
link_current_user_locale_profile_edit = {'text': _('Edit locale profile'), 'view': 'common:current_user_locale_profile_edit', 'icon': 'fa fa-globe'}

View File

@@ -0,0 +1,9 @@
from __future__ import unicode_literals
from navigation import Menu
menu_facet = Menu(name='object facet')
menu_object = Menu(name='object menu')
menu_main = Menu(name='main menu')
menu_secondary = Menu(name='secondary menu')
menu_sidebar = Menu(name='sidebar menu')