1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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)
|