menu and submenu now also uses djangos named urls and url-reverse

This commit is contained in:
fonfon committed 2014-07-10 23:29:06 +03:00
1 parent 809dc4130a
commit 5150efac5f
17 files changed
+68 -55

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@ import cfg
def init():
"""Initailize the apps module"""
cfg.main_menu.add_item("Apps", "icon-download-alt", "/apps", 80)
cfg.main_menu.add_urlname("Apps", "icon-download-alt", "apps:index", 80)
def index(request):
+2 -2
View File
@@ -96,8 +96,8 @@ and must not be greater than 63 characters in length.'),
def init():
"""Initialize the module"""
menu = cfg.main_menu.find('/sys')
menu.add_item(_('Configure'), 'icon-cog', '/sys/config', 10)
menu = cfg.main_menu.get('system:index')
menu.add_urlname(_('Configure'), 'icon-cog', 'config:index', 10)
@login_required
+2 -2
View File
@@ -30,8 +30,8 @@ from errors import ActionError
def init():
"""Initialize the module"""
menu = cfg.main_menu.find('/sys')
menu.add_item("Diagnostics", "icon-screenshot", "/sys/diagnostics", 30)
menu = cfg.main_menu.get('system:index')
menu.add_urlname("Diagnostics", "icon-screenshot", "diagnostics:index", 30)
@login_required
+2 -2
View File
@@ -16,8 +16,8 @@ class ExpertsForm(forms.Form): # pylint: disable-msg=W0232
def init():
"""Initialize the module"""
menu = cfg.main_menu.find('/sys')
menu.add_item(_('Expert Mode'), 'icon-cog', '/sys/expert', 10)
menu = cfg.main_menu.get('system:index')
menu.add_urlname(_('Expert Mode'), 'icon-cog', 'expert_mode:index', 10)
@login_required
+2 -2
View File
@@ -34,8 +34,8 @@ LOGGER = logging.getLogger(__name__)
def init():
"""Initailze firewall module"""
menu = cfg.main_menu.find('/sys')
menu.add_item(_('Firewall'), 'icon-flag', '/sys/firewall', 50)
menu = cfg.main_menu.get('system:index')
menu.add_urlname(_('Firewall'), 'icon-flag', 'firewall:index', 50)
service_module.ENABLED.connect(on_service_enabled)
+9 -7
View File
@@ -8,15 +8,17 @@ import cfg
def init():
"""Initialize the Help module"""
menu = cfg.main_menu.add_item(_('Documentation'), 'icon-book',
'/help/index', 101)
menu.add_item(_("Where to Get Help"), "icon-search", "/help/index", 5)
menu.add_item(_('Developer\'s Manual'), 'icon-info-sign',
'/help/page/plinth', 10)
menu.add_item(_('FAQ'), 'icon-question-sign', '/help/page/faq', 20)
menu = cfg.main_menu.add_urlname(_('Documentation'), 'icon-book',
'help:index', 101)
menu.add_urlname(_("Where to Get Help"), "icon-search",
"help:index_explicit", 5)
menu.add_urlname(_('Developer\'s Manual'), 'icon-info-sign',
'help:helppage', 10, url_args=('plinth',))
menu.add_urlname(_('FAQ'), 'icon-question-sign', 'help:helppage', 20,
url_args=('faq',))
menu.add_item(_('%s Wiki' % cfg.box_name), 'icon-pencil',
'http://wiki.debian.org/FreedomBox', 30)
menu.add_item(_('About'), 'icon-star', '/help/about', 100)
menu.add_urlname(_('About'), 'icon-star', 'help:about', 100)
def index(request):
+5 -4
View File
@@ -20,14 +20,15 @@ URLs for the Help module
"""
from django.conf.urls import patterns, url
from django.core.urlresolvers import reverse_lazy
from django.views.generic import RedirectView
urlpatterns = patterns( # pylint: disable-msg=C0103
'modules.help.help',
url(r'^help/$', RedirectView.as_view(url=reverse_lazy('help:index'))),
url(r'^help/index/$', 'index', name='index'),
# having two urls for one page is a hack to help the current url/menu
# system highlight the correct menu item. Every submenu-item with the same
# url prefix as the main-menu is highlighted automatically.
url(r'^help/$', 'index', name='index'),
url(r'^help/index/$', 'index', name='index_explicit'),
url(r'^help/about/$', 'about', name='about'),
url(r'^help/page/([\w]+)/$', 'helppage', name='helppage'),
)
+2 -2
View File
@@ -19,8 +19,8 @@ class OwnCloudForm(forms.Form): # pylint: disable-msg=W0232
def init():
"""Initialize the ownCloud module"""
menu = cfg.main_menu.find('/apps')
menu.add_item('Owncloud', 'icon-picture', '/apps/owncloud', 35)
menu = cfg.main_menu.get('apps:index')
menu.add_urlname('Owncloud', 'icon-picture', 'owncloud:index', 35)
status = get_status()
+2 -2
View File
@@ -37,8 +37,8 @@ class PackagesForm(forms.Form):
def init():
"""Initialize the Packages module"""
menu = cfg.main_menu.find('/sys')
menu.add_item('Package Manager', 'icon-gift', '/sys/packages', 20)
menu = cfg.main_menu.get('system:index')
menu.add_urlname('Package Manager', 'icon-gift', 'packages:index', 20)
@login_required
+3 -3
View File
@@ -38,9 +38,9 @@ LOGGER = logging.getLogger(__name__)
def init():
"""Intialize the PageKite module"""
menu = cfg.main_menu.find('/apps')
menu.add_item(_('Public Visibility (PageKite)'), 'icon-flag',
'/apps/pagekite', 50)
menu = cfg.main_menu.get('apps:index')
menu.add_urlname(_('Public Visibility (PageKite)'), 'icon-flag',
'pagekite:index', 50)
@login_required
+1 -1
View File
@@ -6,7 +6,7 @@ import cfg
def init():
"""Initialize the system module"""
cfg.main_menu.add_item(_('System'), 'icon-cog', '/sys', 100)
cfg.main_menu.add_urlname(_('System'), 'icon-cog', 'system:index', 100)
def index(request):
+2 -2
View File
@@ -29,8 +29,8 @@ import cfg
def init():
"""Initialize the Tor module"""
menu = cfg.main_menu.find('/apps')
menu.add_item("Tor", "icon-eye-close", "/apps/tor", 30)
menu = cfg.main_menu.get('apps:index')
menu.add_urlname("Tor", "icon-eye-close", "tor:index", 30)
@login_required
+2 -2
View File
@@ -18,8 +18,8 @@ LOGGER = logging.getLogger(__name__)
def init():
"""Intialize the module"""
menu = cfg.main_menu.find('/sys')
menu.add_item(_('Users and Groups'), 'icon-user', '/sys/users', 15)
menu = cfg.main_menu.get('system:index')
menu.add_urlname(_('Users and Groups'), 'icon-user', 'users:index', 15)
@login_required
+16 -7
View File
@@ -1,6 +1,7 @@
from django import forms
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.core.urlresolvers import reverse_lazy
from django.template import RequestContext
from django.template.loader import render_to_string
from django.template.response import TemplateResponse
@@ -14,18 +15,26 @@ import service
LOGGER = logging.getLogger(__name__)
SIDE_MENU = {'title': _('XMPP'),
'items': [{'url': '/apps/xmpp/configure',
'text': 'Configure XMPP Server'},
{'url': '/apps/xmpp/register',
'text': 'Register XMPP Account'}]}
SIDE_MENU = {
'title': _('XMPP'),
'items': [
{
'url': reverse_lazy('xmpp:configure'),
'text': 'Configure XMPP Server'
},
{
'url': reverse_lazy('xmpp:register'),
'text': 'Register XMPP Account'
}
]
}
def init():
"""Initialize the XMPP module"""
menu = cfg.main_menu.find('/apps')
menu = cfg.main_menu.get('apps:index')
menu.add_item('Chat', 'icon-comment', '/../jwchat', 20)
menu.add_item('XMPP', 'icon-comment', '/apps/xmpp', 40)
menu.add_urlname('XMPP', 'icon-comment', 'xmpp:index', 40)
service.Service(
'xmpp-client', _('Chat Server - client connections'),