diff options
author | Simo Sorce <simo@redhat.com> | 2015-03-31 16:35:15 -0400 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2015-04-29 13:30:04 -0400 |
commit | 99b52607ee7ab82cc2b166f99c077ee53375fe1a (patch) | |
tree | 56f0a9279a5d637fb09e294f6ab62ee832d4d751 /ipsilon | |
parent | 68b9e1d3138784c3793f0a04c411f14168748692 (diff) | |
download | ipsilon.git-99b52607ee7ab82cc2b166f99c077ee53375fe1a.tar.gz ipsilon.git-99b52607ee7ab82cc2b166f99c077ee53375fe1a.tar.xz ipsilon.git-99b52607ee7ab82cc2b166f99c077ee53375fe1a.zip |
Merge the login and info plugins configurations
Having separate login and info plugins configuration pages doesn't
really make a lot of sense. As a first step moving towards login stacks
put login and info plugin configuration into a common "Login Stack"
menu item.
https://fedorahosted.org/ipsilon/ticket/117
Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Rob Crittenden <rcritten@redhat.com>
Diffstat (limited to 'ipsilon')
-rw-r--r-- | ipsilon/admin/common.py | 3 | ||||
-rw-r--r-- | ipsilon/admin/info.py | 4 | ||||
-rw-r--r-- | ipsilon/admin/login.py | 4 | ||||
-rw-r--r-- | ipsilon/admin/loginstack.py | 71 | ||||
-rw-r--r-- | ipsilon/root.py | 6 |
5 files changed, 82 insertions, 6 deletions
diff --git a/ipsilon/admin/common.py b/ipsilon/admin/common.py index 76d3fd6..743c71c 100644 --- a/ipsilon/admin/common.py +++ b/ipsilon/admin/common.py @@ -218,6 +218,9 @@ class AdminPlugins(AdminPage): self.order = None parent.add_subtree(name, self) + if self._site[facility] is None: + return + for plugin in self._site[facility].available: cherrypy.log.error('Admin info plugin: %s' % plugin) obj = self._site[facility].available[plugin] diff --git a/ipsilon/admin/info.py b/ipsilon/admin/info.py index 38c8d54..4bc85c4 100644 --- a/ipsilon/admin/info.py +++ b/ipsilon/admin/info.py @@ -1,10 +1,10 @@ # Copyright (C) 2014 Ipsilon Contributors see COPYING for license -from ipsilon.admin.common import AdminPlugins +from ipsilon.admin.loginstack import LoginStackPlugins from ipsilon.info.common import FACILITY -class InfoPlugins(AdminPlugins): +class InfoPlugins(LoginStackPlugins): def __init__(self, site, parent): super(InfoPlugins, self).__init__('info', site, parent, FACILITY) self.title = 'Info Plugins' diff --git a/ipsilon/admin/login.py b/ipsilon/admin/login.py index 0223758..deb1e3d 100644 --- a/ipsilon/admin/login.py +++ b/ipsilon/admin/login.py @@ -1,10 +1,10 @@ # Copyright (C) 2014 Ipsilon Contributors see COPYING for license -from ipsilon.admin.common import AdminPlugins +from ipsilon.admin.loginstack import LoginStackPlugins from ipsilon.login.common import FACILITY -class LoginPlugins(AdminPlugins): +class LoginPlugins(LoginStackPlugins): def __init__(self, site, parent): super(LoginPlugins, self).__init__('login', site, parent, FACILITY) self.title = 'Login Plugins' diff --git a/ipsilon/admin/loginstack.py b/ipsilon/admin/loginstack.py new file mode 100644 index 0000000..1faa089 --- /dev/null +++ b/ipsilon/admin/loginstack.py @@ -0,0 +1,71 @@ +# Copyright (C) 2014 Ipsilon Contributors see COPYING for license + +from ipsilon.admin.common import AdminPlugins + + +FACILITY = 'login stack' + + +class LoginStackPlugins(AdminPlugins): + + def __init__(self, name, site, parent, facility, **kwargs): + super(LoginStackPlugins, self).__init__(name, site, parent, + facility, **kwargs) + self.parent = parent + + def root_with_msg(self, message=None, message_type=None, changed=None): + return self.parent.root_with_msg(message, message_type, changed) + + +class LoginStack(AdminPlugins): + def __init__(self, site, parent): + self.children = [] + site[FACILITY] = None + super(LoginStack, self).__init__('loginstack', site, parent, FACILITY) + self.title = 'Login Stack' + self.template = 'admin/loginstack.html' + + def add_subtree(self, name, page): + self.__dict__[name] = page + self.children.append(page) + + def del_subtree(self, name): + self.children.remove(self.__dict__[name]) + del self.__dict__[name] + + def get_children_urls(self): + urls = dict() + for item in self.children: + name = getattr(item, 'name', None) + if name: + urls['%s_url' % name] = cherrypy.url('/%s/%s' % (self.mount, + name)) + return urls + + def root_with_msg(self, message=None, message_type=None, changed=None): + # Force the url to be that of the Login Stack + kwargs = {'title': self.title, + 'menu': self._master.menu, + 'message': message, + 'message_type': message_type, + 'newurl': self.url, + 'sections': list()} + for child in self.children: + plugins = child._site[child.facility] + + if changed is None: + changed = dict() + + targs = {'title': child.title, + 'available': plugins.available, + 'enabled': plugins.enabled, + 'changed': changed, + 'baseurl': child.url} + if child.order: + targs['order_name'] = '%s_order_form' % child.name + targs['order_action'] = child.order.url + + kwargs['sections'].append(targs) + + # pylint: disable=star-args + return self._template(self.template, **kwargs) diff --git a/ipsilon/root.py b/ipsilon/root.py index 93b6cd4..6326436 100644 --- a/ipsilon/root.py +++ b/ipsilon/root.py @@ -21,6 +21,7 @@ from ipsilon.login.common import Login from ipsilon.login.common import Logout from ipsilon.admin.common import Admin from ipsilon.providers.common import LoadProviders +from ipsilon.admin.loginstack import LoginStack from ipsilon.admin.info import InfoPlugins from ipsilon.admin.login import LoginPlugins from ipsilon.admin.providers import ProviderPlugins @@ -57,8 +58,9 @@ class Root(Page): # after all plugins are setup we can instantiate the admin pages self.admin = Admin(self._site, 'admin') self.rest = Rest(self._site, 'rest') - InfoPlugins(self._site, self.admin) - LoginPlugins(self._site, self.admin) + self.stack = LoginStack(self._site, self.admin) + LoginPlugins(self._site, self.stack) + InfoPlugins(self._site, self.stack) ProviderPlugins(self._site, self.admin) RestProviderPlugins(self._site, self.rest) |