Skip to content

Commit

Permalink
feat: Initial help menu
Browse files Browse the repository at this point in the history
  • Loading branch information
marksweb committed Jul 16, 2021
1 parent 53dddb1 commit 2182857
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cms/cms_toolbars.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
# Identifiers for search
ADMIN_MENU_IDENTIFIER = 'admin-menu'
LANGUAGE_MENU_IDENTIFIER = 'language-menu'
HELP_MENU_IDENTIFIER = 'help-menu'
TEMPLATE_MENU_BREAK = 'Template Menu Break'
PAGE_MENU_IDENTIFIER = 'page'
PAGE_MENU_ADD_IDENTIFIER = 'add_page'
Expand Down Expand Up @@ -104,6 +105,7 @@ def populate(self):
self.clipboard = self.request.toolbar.user_settings.clipboard
self.add_admin_menu()
self.add_language_menu()
self.add_help_menu()

def add_admin_menu(self):
if not self._admin_menu:
Expand Down Expand Up @@ -207,6 +209,14 @@ def add_language_menu(self):
url = DefaultLanguageChanger(self.request)(code)
self._language_menu.add_link_item(name, url=url, active=self.current_lang == code)

def add_help_menu(self):
""" Adds the help menu if it's enabled in settings """
if get_cms_setting('ENABLE_HELP'):
self._help_menu = self.toolbar.get_or_create_menu(HELP_MENU_IDENTIFIER, _('Help'), position=-1)
menu_items = get_cms_setting('HELP_MENU_ITEMS')
for label, url in menu_items:
self._help_menu.add_link_item(label, url=url)

def get_username(self, user=None, default=''):
user = user or self.request.user
try:
Expand Down
7 changes: 7 additions & 0 deletions cms/utils/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ def wrapper():
'PAGE_WIZARD_CONTENT_PLUGIN': 'TextPlugin',
'PAGE_WIZARD_CONTENT_PLUGIN_BODY': 'body',
'PAGE_WIZARD_CONTENT_PLACEHOLDER': None, # Use first placeholder it finds.
'ENABLE_HELP': True, # Adds help menu toolbar
'HELP_MENU_ITEMS': (
(_('Community forum'), 'https://discourse.django-cms.org/'),
(_('Documentation'), 'https://docs.django-cms.org/en/latest/'),
(_('Getting started'), 'https://www.django-cms.org/en/get-started-django-cms/'),
(_('Talk to us'), 'https://www.django-cms.org/en/support/'),
)
}


Expand Down
24 changes: 24 additions & 0 deletions docs/reference/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,30 @@ Example::
.. _unihandecode.js: https://github.com/ojii/unihandecode.js


CMS_HELP_MENU
=============

default
``True``

This setting controls if the help menu appears in the toolbar.


CMS_HELP_MENU_ITEMS
===================

default::

CMS_HELP_MENU_ITEMS = (
(_('Community forum'), 'https://discourse.django-cms.org/'),
(_('Documentation'), 'https://docs.django-cms.org/en/latest/'),
(_('Getting started'), 'https://www.django-cms.org/en/get-started-django-cms/'),
(_('Talk to us'), 'https://www.django-cms.org/en/support/'),
)

This setting overrides the default links of the support menu.


CMS_TOOLBAR_ANONYMOUS_ON
========================

Expand Down

0 comments on commit 2182857

Please sign in to comment.