mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
removed unused 'title' from subsubmenus
This commit is contained in:
parent
61fefcff01
commit
ae83566653
@ -34,11 +34,10 @@ from plinth import cfg
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
subsubmenu = {'title': _('PageKite'),
|
||||
'items': [{'url': reverse_lazy('pagekite:index'),
|
||||
'text': _('About PageKite')},
|
||||
{'url': reverse_lazy('pagekite:configure'),
|
||||
'text': _('Configure PageKite')}]}
|
||||
subsubmenu = [{'url': reverse_lazy('pagekite:index'),
|
||||
'text': _('About PageKite')},
|
||||
{'url': reverse_lazy('pagekite:configure'),
|
||||
'text': _('Configure PageKite')}]
|
||||
|
||||
|
||||
def init():
|
||||
@ -194,7 +193,7 @@ def _apply_changes(request, old_status, new_status):
|
||||
|
||||
|
||||
def _run(arguments, superuser=True):
|
||||
"""Run an given command and raise exception if there was an error"""
|
||||
"""Run a given command and raise exception if there was an error"""
|
||||
command = 'pagekite-configure'
|
||||
|
||||
if superuser:
|
||||
|
||||
@ -28,18 +28,14 @@ from django.views.generic import ListView
|
||||
from gettext import gettext as _
|
||||
|
||||
|
||||
# TODO: we do not use the title anymore, and 'items' is also a python keyword.
|
||||
# For all subsubmenus: let's remove title and just use the items list directly.
|
||||
# Make sure to update the tests too.
|
||||
subsubmenu = {'title': _('Users and Groups'),
|
||||
'items': [{'url': reverse_lazy('users:index'),
|
||||
'text': _('Users')},
|
||||
{'url': reverse_lazy('users:create'),
|
||||
'text': _('Create User')}]}
|
||||
subsubmenu = [{'url': reverse_lazy('users:index'),
|
||||
'text': _('Users')},
|
||||
{'url': reverse_lazy('users:create'),
|
||||
'text': _('Create User')}]
|
||||
|
||||
|
||||
class ContextMixin(object):
|
||||
"""View to add 'subsubmenu' and 'title' to the context."""
|
||||
"""Mixin to add 'subsubmenu' and 'title' to the context."""
|
||||
def get_context_data(self, **kwargs):
|
||||
"""Use self.title and the module-level subsubmenu"""
|
||||
context = super(ContextMixin, self).get_context_data(**kwargs)
|
||||
|
||||
@ -30,23 +30,12 @@ from plinth import service
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
subsubmenu = {
|
||||
'title': _('XMPP'),
|
||||
'items': [
|
||||
{
|
||||
'url': reverse_lazy('xmpp:index'),
|
||||
'text': _('About'),
|
||||
},
|
||||
{
|
||||
'url': reverse_lazy('xmpp:configure'),
|
||||
'text': _('Configure XMPP Server'),
|
||||
},
|
||||
{
|
||||
'url': reverse_lazy('xmpp:register'),
|
||||
'text': _('Register XMPP Account'),
|
||||
}
|
||||
]
|
||||
}
|
||||
subsubmenu = [{'url': reverse_lazy('xmpp:index'),
|
||||
'text': _('About')},
|
||||
{'url': reverse_lazy('xmpp:configure'),
|
||||
'text': _('Configure XMPP Server')},
|
||||
{'url': reverse_lazy('xmpp:register'),
|
||||
'text': _('Register XMPP Account')}]
|
||||
|
||||
|
||||
def init():
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
{% endcomment %}
|
||||
|
||||
<ul class="nav nav-tabs">
|
||||
{% for urlitem in subsubmenu.items %}
|
||||
{% for urlitem in subsubmenu %}
|
||||
<li {% if urlitem.active %} class="active"{% endif %}
|
||||
role="presentation">
|
||||
<a href="{{ urlitem.url }}">{{ urlitem.text }}</a>
|
||||
|
||||
@ -25,9 +25,7 @@ def mark_active_menuitem(menu, path):
|
||||
"""Mark the best-matching menu item with 'active'
|
||||
|
||||
Input: a menu dict in the form of:
|
||||
{'title': 'foo menu',
|
||||
'items': [{'url': '/path/to/choice1/', 'text': 'choice 1'}, {'url': ...}]
|
||||
}
|
||||
[{'url': '/path/to/choice1/', 'text': 'choice 1'}, {'url': ...}]
|
||||
|
||||
URL paths are expected to end with a slash for matches to work properly.
|
||||
|
||||
@ -39,7 +37,7 @@ def mark_active_menuitem(menu, path):
|
||||
best_match = ''
|
||||
best_match_item = None
|
||||
|
||||
for urlitem in menu['items']:
|
||||
for urlitem in menu:
|
||||
urlitem['active'] = False
|
||||
if not path.startswith(str(urlitem['url'])):
|
||||
continue
|
||||
|
||||
@ -24,7 +24,7 @@ class TestShowSubSubMenu(unittest.TestCase):
|
||||
"""Verify that the highlighting of the subsubmenu is working correctly"""
|
||||
def assert_active_url(self, menu, url):
|
||||
"""Verify that only the given url is set as 'active' in the menu"""
|
||||
for item in menu['items']:
|
||||
for item in menu:
|
||||
if item['url'] == url:
|
||||
self.assertTrue(item['active'])
|
||||
else:
|
||||
@ -32,17 +32,14 @@ class TestShowSubSubMenu(unittest.TestCase):
|
||||
|
||||
def _verify_active_menuitems(self, menu):
|
||||
"""Verify that one and only one menuitem is marked as active"""
|
||||
return sum([item['active'] for item in menu['items']]) == 1
|
||||
return sum([item['active'] for item in menu]) == 1
|
||||
|
||||
def test_highlighting(self):
|
||||
"""Test detection of active subsubmenu items using request.path"""
|
||||
menu = {
|
||||
'text': 'blubb',
|
||||
'items': [{'url': '/abc/123/abc/', 'text': 'abc'},
|
||||
{'url': '/abc/123/', 'text': 'overview'},
|
||||
{'url': '/abc/123/crunch/', 'text': 'crunch'},
|
||||
{'url': '/abc/123/create/', 'text': 'create'}]
|
||||
}
|
||||
menu = [{'url': '/abc/123/abc/', 'text': 'abc'},
|
||||
{'url': '/abc/123/', 'text': 'overview'},
|
||||
{'url': '/abc/123/crunch/', 'text': 'crunch'},
|
||||
{'url': '/abc/123/create/', 'text': 'create'}]
|
||||
|
||||
tests = [['/abc/123/crunch/new/', '/abc/123/crunch/'],
|
||||
['/abc/123/create/', '/abc/123/create/'],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user