Add links to the documentation, support page, forum and source in

the about menu. Make the about menu a nested menu.
This commit is contained in:
Roberto Rosario
2017-01-16 01:50:14 -04:00
parent 617df3bedb
commit a3c1b0873d
6 changed files with 73 additions and 61 deletions

View File

@@ -69,19 +69,7 @@
</p>
<p class="text-center">
<i class="fa fa-link"></i><a href="{% project_website %}"> {% project_website %}</a>
</p>
<p class="text-center">
<i class="fa fa-book"></i> <a href="http://readthedocs.org/docs/mayan/en/latest/"> http://mayan.readthedocs.org/</a>
</p>
<p class="text-center">
<i class="fa fa-wrench"></i> <a href="https://gitlab.com/mayan-edms/mayan-edms/"> https://gitlab.com/mayan-edms/mayan-edms/</a>
</p>
<p class="text-center">
<i class="fa fa-bug"></i> <a href="https://gitlab.com/mayan-edms/mayan-edms/issues"> https://gitlab.com/mayan-edms/mayan-edms/issues</a>
<i class="fa fa-home"></i><a href="{% project_website %}"> {% project_website %}</a>
</p>
<p class="text-center">

View File

@@ -2,8 +2,8 @@
<li role="separator" class="divider"></li>
{% else %}
{% 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 %}&nbsp;{% endif %}{% endif %}
<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 %} {% if 'new_window' in link.tags %}new_window{% 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 %}&nbsp;{% 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 %}&nbsp;{% endif %}{% endif %}
<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 %} {% if 'new_window' in link.tags %}new_window{% 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 %}&nbsp;{% endif %}{% endif %}
{% endif %}
{% endif %}

View File

@@ -13,17 +13,19 @@ from django.db.models.signals import post_save
from django.utils.translation import ugettext_lazy as _
from mayan.celery import app
from navigation.classes import Separator
from .handlers import (
user_locale_profile_session_config, user_locale_profile_create
)
from .links import (
link_about, link_current_user_details, link_current_user_edit,
link_current_user_locale_profile_edit, link_filters, link_license,
link_packages_licenses, link_setup, link_tools
link_about, link_code, link_current_user_details, link_current_user_edit,
link_current_user_locale_profile_edit, link_documentation, link_filters,
link_forum, link_license, link_packages_licenses, link_setup, link_support,
link_tools
)
from .literals import DELETE_STALE_UPLOADS_INTERVAL
from .menus import menu_facet, menu_main, menu_tools, menu_user
from .menus import menu_about, menu_facet, menu_main, menu_tools, menu_user
from .licenses import * # NOQA
from .settings import setting_auto_logging
from .tasks import task_delete_stale_uploads # NOQA - Force task registration
@@ -106,7 +108,6 @@ class CommonApp(MayanAppConfig):
},
}
)
from navigation.classes import Separator
menu_user.bind_links(
links=(
link_current_user_details, link_current_user_edit,
@@ -115,14 +116,14 @@ class CommonApp(MayanAppConfig):
)
)
menu_facet.bind_links(
links=(link_about, link_license, link_packages_licenses),
sources=(
'common:about_view', 'common:license_view',
'common:packages_licenses_view'
menu_about.bind_links(
links=(
link_about, link_support, link_documentation, link_forum,
link_code, link_license, link_packages_licenses,
)
)
menu_main.bind_links(links=(link_about,), position=99)
menu_main.bind_links(links=(menu_about,), position=99)
menu_tools.bind_links(
links=(link_filters,)

View File

@@ -6,7 +6,7 @@ from navigation import Link
link_about = Link(
icon='fa fa-question', text=_('About'), view='common:about_view'
icon='fa fa-info', text=_('About this'), view='common:about_view'
)
link_current_user_details = Link(
icon='fa fa-user', text=_('User details'),
@@ -23,20 +23,36 @@ link_current_user_locale_profile_edit = Link(
icon='fa fa-globe', text=_('Edit locale profile'),
view='common:current_user_locale_profile_edit'
)
link_code = Link(
icon='fa fa-code-fork', tags='new_window', text=_('Source code'),
url='https://gitlab.com/mayan-edms/mayan-edms'
)
link_documentation = Link(
icon='fa fa-book', tags='new_window', text=_('Documentation'),
url='https://mayan.readthedocs.io/en/stable/'
)
link_filters = Link(
icon='fa fa-filter', text=_('Data filters'),
view='common:filter_selection'
)
link_forum = Link(
icon='fa fa-life-ring', tags='new_window', text=_('Forum'),
url='https://groups.google.com/forum/#!forum/mayan-edms'
)
link_license = Link(
icon='fa fa-book', text=_('License'), view='common:license_view'
icon='fa fa-certificate', text=_('License'), view='common:license_view'
)
link_packages_licenses = Link(
icon='fa fa-book', text=_('Other packages licenses'),
icon='fa fa-certificate', text=_('Other packages licenses'),
view='common:packages_licenses_view'
)
link_setup = Link(
icon='fa fa-gear', text=_('Setup'), view='common:setup_list'
)
link_support = Link(
icon='fa fa-phone', tags='new_window', text=_('Support'),
url='http://www.mayan-edms.com/providers/'
)
link_tools = Link(
icon='fa fa-wrench', text=_('Tools'), view='common:tools_list'
)

View File

@@ -1,12 +1,15 @@
from __future__ import unicode_literals
from django.utils.translation import ugettext_lazy as _
from navigation import Menu
__all__ = (
'menu_facet', 'menu_object', 'menu_main', 'menu_multi_item',
'menu_about', 'menu_facet', 'menu_object', 'menu_main', 'menu_multi_item',
'menu_secondary', 'menu_setup', 'menu_sidebar', 'menu_tools', 'menu_user'
)
menu_about = Menu(icon='fa fa-info', label=_('About'), name='about menu')
menu_facet = Menu(name='object facet')
menu_object = Menu(name='object menu')
menu_main = Menu(name='main menu')

View File

@@ -236,10 +236,11 @@ class Menu(object):
class Link(object):
def __init__(self, text, view, args=None, condition=None,
def __init__(self, text, 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):
permissions_related=None, remove_from_query=None, tags=None,
url=None):
self.args = args or []
self.condition = condition
@@ -254,6 +255,7 @@ class Link(object):
self.tags = tags
self.text = text
self.view = view
self.url = url
def resolve(self, context, resolved_object=None):
AccessControlList = apps.get_model(
@@ -299,40 +301,42 @@ class Link(object):
resolved_link = ResolvedLink(current_view=current_view, link=self)
view_name = Variable('"{}"'.format(self.view))
if isinstance(self.args, list) or isinstance(self.args, tuple):
# TODO: Don't check for instance check for iterable in try/except
# block. This update required changing all 'args' argument in
# links.py files to be iterables and not just strings.
args = [Variable(arg) for arg in self.args]
else:
args = [Variable(self.args)]
if self.view:
view_name = Variable('"{}"'.format(self.view))
if isinstance(self.args, list) or isinstance(self.args, tuple):
# TODO: Don't check for instance check for iterable in try/except
# block. This update required changing all 'args' argument in
# links.py files to be iterables and not just strings.
args = [Variable(arg) for arg in self.args]
else:
args = [Variable(self.args)]
# If we were passed an instance of the view context object we are
# resolving, inject it into the context. This help resolve links for
# object lists.
if resolved_object:
context['resolved_object'] = resolved_object
# If we were passed an instance of the view context object we are
# resolving, inject it into the context. This help resolve links for
# object lists.
if resolved_object:
context['resolved_object'] = resolved_object
try:
kwargs = self.kwargs(context)
except TypeError:
# Is not a callable
kwargs = self.kwargs
try:
kwargs = self.kwargs(context)
except TypeError:
# Is not a callable
kwargs = self.kwargs
kwargs = {key: Variable(value) for key, value in kwargs.iteritems()}
kwargs = {key: Variable(value) for key, value in kwargs.iteritems()}
# Use Django's exact {% url %} code to resolve the link
node = URLNode(
view_name=view_name, args=args, kwargs=kwargs, asvar=None
)
try:
resolved_link.url = node.render(context)
except Exception as exception:
logger.error(
'Error resolving link "%s" URL; %s', self.text, exception
# Use Django's exact {% url %} code to resolve the link
node = URLNode(
view_name=view_name, args=args, kwargs=kwargs, asvar=None
)
try:
resolved_link.url = node.render(context)
except Exception as exception:
logger.error(
'Error resolving link "%s" URL; %s', self.text, exception
)
elif self.url:
resolved_link.url = self.url
# This is for links that should be displayed but that are not clickable
if self.conditional_disable: