diff options
author | Simo Sorce <simo@redhat.com> | 2015-03-31 16:35:15 -0400 |
---|---|---|
committer | Simo Sorce <simo@redhat.com> | 2015-03-31 16:35:15 -0400 |
commit | a434d2da8d8df588f269a3e2a6c80c355586ed9b (patch) | |
tree | a4a507d43704e6991f88dd463ce57a2f92ef3a50 /ipsilon/admin/loginstack.py | |
parent | f7150fdefeb58ab4e33f742969ebbc6019f45b08 (diff) | |
download | ipsilon-review.tar.gz ipsilon-review.tar.xz ipsilon-review.zip |
Merge the login and info plugins configurationsreview
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.
Signed-off-by: Simo Sorce <simo@redhat.com>
Diffstat (limited to 'ipsilon/admin/loginstack.py')
-rw-r--r-- | ipsilon/admin/loginstack.py | 71 |
1 files changed, 71 insertions, 0 deletions
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) |