summaryrefslogtreecommitdiffstats
path: root/ipsilon
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2014-03-26 15:44:26 -0400
committerSimo Sorce <simo@redhat.com>2014-03-28 14:12:08 -0400
commitdbcead832f700ad63dc382648f0e3b1b84cd4d23 (patch)
treec19d561ac718ad1620c0e5568ae759e99b0c5390 /ipsilon
parent134914682267592e2b42276255aff24bd2fabe6b (diff)
downloadipsilon-dbcead832f700ad63dc382648f0e3b1b84cd4d23.tar.gz
ipsilon-dbcead832f700ad63dc382648f0e3b1b84cd4d23.tar.xz
ipsilon-dbcead832f700ad63dc382648f0e3b1b84cd4d23.zip
Automatically build configuration page menu
Do not hardcode it, rather build it out of the pages tree. Signed-off-by: Simo Sorce <simo@redhat.com>
Diffstat (limited to 'ipsilon')
-rwxr-xr-xipsilon/admin/common.py31
-rwxr-xr-xipsilon/admin/login.py24
2 files changed, 35 insertions, 20 deletions
diff --git a/ipsilon/admin/common.py b/ipsilon/admin/common.py
index 0a46797..18b71ab 100755
--- a/ipsilon/admin/common.py
+++ b/ipsilon/admin/common.py
@@ -25,11 +25,13 @@ from ipsilon.util.page import admin_protect
class AdminPluginPage(Page):
- def __init__(self, obj, site, baseurl, facility):
+ def __init__(self, obj, site, parent):
super(AdminPluginPage, self).__init__(site)
self._obj = obj
- self.url = '%s/%s' % (baseurl, obj.name)
- self.facility = facility
+ self.title = '%s plugin' % obj.name
+ self.url = '%s/%s' % (parent.url, obj.name)
+ self.facility = parent.facility
+ self.menu = [parent]
# Get the defaults
self.plugin_config = obj.get_config_desc()
@@ -42,11 +44,10 @@ class AdminPluginPage(Page):
@admin_protect
def GET(self, *args, **kwargs):
- return self._template('admin/plugin_config.html',
- title='%s plugin' % self._obj.name,
+ return self._template('admin/plugin_config.html', title=self.title,
name='admin_%s_%s_form' % (self.facility,
self._obj.name),
- action=self.url,
+ menu=self.menu, action=self.url,
options=self.plugin_config)
@admin_protect
@@ -80,13 +81,12 @@ class AdminPluginPage(Page):
self._obj.set_config_value(name, value)
self.plugin_config[name][2] = value
- return self._template('admin/plugin_config.html',
+ return self._template('admin/plugin_config.html', title=self.title,
message=message,
message_type=message_type,
- title='%s plugin' % self._obj.name,
name='admin_%s_%s_form' % (self.facility,
self._obj.name),
- action=self.url,
+ menu=self.menu, action=self.url,
options=self.plugin_config)
def root(self, *args, **kwargs):
@@ -101,6 +101,17 @@ class Admin(Page):
def __init__(self, site, mount):
super(Admin, self).__init__(site)
self.url = '%s/%s' % (self.basepath, mount)
+ self.menu = []
def root(self, *args, **kwargs):
- return self._template('admin/index.html', title='Configuration')
+ return self._template('admin/index.html',
+ title='Configuration',
+ menu=self.menu)
+
+ def add_subtree(self, name, page):
+ self.__dict__[name] = page
+ self.menu.append(page)
+
+ def del_subtree(self, name):
+ self.menu.remove(self.__dict__[name])
+ del self.__dict__[name]
diff --git a/ipsilon/admin/login.py b/ipsilon/admin/login.py
index 1f5e9fa..b8325c8 100755
--- a/ipsilon/admin/login.py
+++ b/ipsilon/admin/login.py
@@ -27,16 +27,17 @@ from ipsilon.login.common import FACILITY
class LoginPluginsOrder(Page):
- def __init__(self, site, baseurl):
+ def __init__(self, site, parent):
super(LoginPluginsOrder, self).__init__(site)
- self.url = '%s/order' % baseurl
+ self.url = '%s/order' % parent.url
+ self.menu = [parent]
@admin_protect
def GET(self, *args, **kwargs):
return self._template('admin/login_order.html',
title='login plugins order',
name='admin_login_order_form',
- action=self.url,
+ menu=self.menu, action=self.url,
options=self._site[FACILITY]['enabled'])
@admin_protect
@@ -87,7 +88,7 @@ class LoginPluginsOrder(Page):
message_type=message_type,
title='login plugins order',
name='admin_login_order_form',
- action=self.url,
+ menu=self.menu, action=self.url,
options=self._site[FACILITY]['enabled'])
def root(self, *args, **kwargs):
@@ -100,19 +101,22 @@ class LoginPluginsOrder(Page):
class LoginPlugins(Page):
def __init__(self, site, parent):
super(LoginPlugins, self).__init__(site)
- parent.login = self
+ self._master = parent
+ self.title = 'Login Plugins'
self.url = '%s/login' % parent.url
+ self.facility = FACILITY
+ parent.add_subtree('login', self)
for plugin in self._site[FACILITY]['available']:
cherrypy.log.error('Admin login plugin: %s' % plugin)
obj = self._site[FACILITY]['available'][plugin]
- self.__dict__[plugin] = AdminPluginPage(obj, self._site,
- self.url, FACILITY)
+ self.__dict__[plugin] = AdminPluginPage(obj, self._site, self)
- self.order = LoginPluginsOrder(self._site, self.url)
+ self.order = LoginPluginsOrder(self._site, self)
def root(self, *args, **kwargs):
login_plugins = self._site[FACILITY]
- return self._template('admin/login.html', title='Login Plugins',
+ return self._template('admin/login.html', title=self.title,
available=login_plugins['available'],
- enabled=login_plugins['enabled'])
+ enabled=login_plugins['enabled'],
+ menu=self._master.menu)