本文整理汇总了Python中freenasUI.freeadmin.tree.TreeNode.order方法的典型用法代码示例。如果您正苦于以下问题:Python TreeNode.order方法的具体用法?Python TreeNode.order怎么用?Python TreeNode.order使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类freenasUI.freeadmin.tree.TreeNode
的用法示例。
在下文中一共展示了TreeNode.order方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from freenasUI.freeadmin.tree import TreeNode [as 别名]
# 或者: from freenasUI.freeadmin.tree.TreeNode import order [as 别名]
def __init__(self, *args, **kwargs):
super(Volumes, self).__init__(*args, **kwargs)
self.append_children([
AddVolume(),
ImportVolume(),
AutoImportVolume(),
ViewVolumes(),
ViewDisks(),
])
if not appPool.hook_feature_disabled('ufs'):
self.append_child(AddVolumeUFS())
has_multipath = models.Disk.objects.exclude(
disk_multipath_name=''
).exists()
if has_multipath:
self.append_child(ViewMultipaths())
mp = models.MountPoint.objects.select_related().order_by('-id')
for i in mp:
nav = TreeNode(i.mp_volume.id)
nav.name = i.mp_path
nav.order = -i.id
nav.model = 'Volume'
nav.kwargs = {'oid': i.mp_volume.id, 'model': 'Volume'}
nav.icon = u'VolumesIcon'
if i.mp_volume.vol_fstype == 'ZFS':
ds = TreeNode('Dataset')
ds.name = _(u'Create ZFS Dataset')
ds.view = 'storage_dataset'
ds.icon = u'AddDatasetIcon'
ds.type = 'object'
ds.kwargs = {'fs': i.mp_volume.vol_name}
nav.append_child(ds)
zv = AddZVol()
zv.kwargs = {'parent': i.mp_volume.vol_name}
nav.append_child(zv)
subnav = TreeNode('ChangePermissions')
subnav.name = _('Change Permissions')
subnav.type = 'editobject'
subnav.view = 'storage_mp_permission'
subnav.kwargs = {'path': i.mp_path}
subnav.model = 'Volume'
subnav.icon = u'ChangePasswordIcon'
subnav.app_name = 'storage'
datasets = i.mp_volume.get_datasets(hierarchical=True)
if datasets:
for name, d in datasets.items():
# TODO: non-recursive algo
self._gen_dataset(nav, d)
nav.append_child(subnav)
self.insert_child(0, nav)
示例2: __init__
# 需要导入模块: from freenasUI.freeadmin.tree import TreeNode [as 别名]
# 或者: from freenasUI.freeadmin.tree.TreeNode import order [as 别名]
def __init__(self, *args, **kwargs):
super(Volumes, self).__init__(*args, **kwargs)
self.append_children([
AddVolume(),
ImportDisk(),
ImportVolume(),
ViewVolumes(),
ViewDisks(),
])
if not notifier().is_freenas():
self.append_child(ViewEnclosure())
has_multipath = models.Disk.objects.exclude(
disk_multipath_name=''
).exists()
if has_multipath:
self.append_child(ViewMultipaths())
for i in models.Volume.objects.order_by('-id'):
nav = TreeNode(i.id)
nav.name = i.vol_path
nav.order = -i.id
nav.model = 'Volume'
nav.kwargs = {'oid': i.id, 'model': 'Volume'}
nav.icon = 'VolumesIcon'
ds = TreeNode('Dataset')
ds.name = _('Create Dataset')
ds.view = 'storage_dataset'
ds.icon = 'AddDatasetIcon'
ds.type = 'object'
ds.kwargs = {'fs': i.vol_name}
nav.append_child(ds)
zv = AddZVol()
zv.kwargs = {'parent': i.vol_name}
nav.append_child(zv)
subnav = TreeNode('ChangePermissions')
subnav.name = _('Change Permissions')
subnav.type = 'editobject'
subnav.view = 'storage_mp_permission'
subnav.kwargs = {'path': i.vol_path}
subnav.model = 'Volume'
subnav.icon = 'ChangePasswordIcon'
subnav.app_name = 'storage'
datasets = i.get_datasets(hierarchical=True)
if datasets:
for name, d in list(datasets.items()):
# TODO: non-recursive algo
self._gen_dataset(nav, d)
nav.append_child(subnav)
self.insert_child(0, nav)
示例3: _generate_app
# 需要导入模块: from freenasUI.freeadmin.tree import TreeNode [as 别名]
# 或者: from freenasUI.freeadmin.tree.TreeNode import order [as 别名]
def _generate_app(self, app, request, tree_roots, childs_of):
# Thats the root node for the app tree menu
nav = TreeRoot(app.split(".")[-1])
modnav = self._get_module(app, 'nav')
if hasattr(modnav, 'BLACKLIST'):
BLACKLIST = modnav.BLACKLIST
else:
BLACKLIST = []
if hasattr(modnav, 'ICON'):
nav.icon = modnav.ICON
if hasattr(modnav, 'NAME'):
nav.name = modnav.NAME
else:
nav.name = self.titlecase(app)
if hasattr(modnav, 'TYPE'):
nav.type = modnav.TYPE
if hasattr(modnav, 'HIDE'):
nav.skip = modnav.HIDE
if hasattr(modnav, 'URL'):
nav.url = reverse(modnav.URL)
if modnav:
modname = "%s.nav" % app
for c in dir(modnav):
navc = getattr(modnav, c)
try:
subclass = issubclass(navc, TreeNode)
except TypeError:
continue
if navc.__module__ == modname and subclass:
obj = navc(request=request)
if obj.skip is True:
continue
if not obj.append_to:
self.register_option(obj, nav, replace=True)
else:
self._navs[obj.append_to + '.' + obj.gname] = obj
tree_roots.register(nav) # We register it to the tree root
if hasattr(modnav, 'init'):
modnav.init(tree_roots, nav, request)
appPool.hook_nav_init(nav.gname, tree_roots, nav, request)
else:
log.debug("App %s has no nav.py module, skipping", app)
return
modmodels = self._get_module(app, 'models')
if modmodels:
modname = '%s.models' % app
for c in dir(modmodels):
model = getattr(modmodels, c)
try:
if issubclass(model, models.Model):
if model._meta.app_label == app:
continue
else:
continue
except TypeError, e:
continue
if c in BLACKLIST:
log.debug(
"Model %s from app %s blacklisted, skipping",
c,
app,
)
continue
if not (
model.__module__ in (
modname,
'freenasUI.' + modname,
)
and
model in self._modelforms
):
log.debug("Model %s does not have a ModelForm", model)
continue
if model._admin.deletable is False:
navopt = TreeNode(
str(model._meta.object_name),
name=model._meta.verbose_name,
model=c, app_name=app, type='dialog')
try:
navopt.kwargs = {
'oid': model.objects.order_by("-id")[0].id,
}
navopt.view = 'freeadmin_%s_%s_edit' % (
#.........这里部分代码省略.........
示例4: __init__
# 需要导入模块: from freenasUI.freeadmin.tree import TreeNode [as 别名]
# 或者: from freenasUI.freeadmin.tree.TreeNode import order [as 别名]
def __init__(self, *args, **kwargs):
super(ViewPluginJails, self).__init__(*args, **kwargs)
request = kwargs.get('request')
host = get_base_url(request)
jails = Jails.objects.filter(jail_type=WARDEN_TYPE_PLUGINJAIL)
for jail in jails:
jail_node = self.new_jail_node(jail, u'JailPluginIcon')
self.append_child(jail_node)
jail_node_view = self.new_jail_node_view(jail)
jail_node_view.order = 1
jail_node.append_child(jail_node_view)
storage_node = self.new_storage_node(jail)
storage_node.order = 2
jail_node.append_child(storage_node)
storage_order = 1
nmps = NullMountPoint.objects.filter(jail=jail.jail_host)
for nmp in nmps:
storage_node_view = self.new_storage_node_view(nmp)
storage_node_view.order = storage_order
storage_node.append_child(storage_node_view)
storage_order += 1
storage_node_mkdir = self.new_storage_node_mkdir(jail)
storage_node_mkdir.order = storage_order
storage_node.append_child(storage_node_mkdir)
storage_order += 1
storage_node_add = self.new_storage_node_add(jail)
storage_node_add.order = storage_order
storage_node.append_child(storage_node_add)
plugin_node = TreeNode()
plugin_node.gname = 'Plugins'
plugin_node.name = _(u'Plugins')
plugin_node.icon = u'PluginIcon'
plugin_node.order = 3
args = map(
lambda y: (y, host, request),
Plugins.objects.filter(plugin_enabled=True, plugin_jail=jail.jail_host))
plugin_order = 1
pool = eventlet.GreenPool(20)
for plugin, url, data in pool.imap(self.plugin_fetch, args):
if not data:
continue
try:
data = simplejson.loads(data)
nodes = unserialize_tree(data)
for node in nodes:
node.order = plugin_order
plugin_node.append_child(node)
plugin_order += 1
except Exception, e:
log.warn(_(
"An error occurred while unserializing from "
"%(url)s: %(error)s") % {'url': url, 'error': e})
log.debug(_(
"Error unserializing %(url)s (%(error)s), data "
"retrieved:") % {
'url': url,
'error': e,
})
for line in data.splitlines():
log.debug(line)
continue
plugin_node_add = TreeNode()
plugin_node_add.name = _('Install Plugin')
plugin_node_add.type = 'editobject'
plugin_node_add.view = 'plugin_install'
plugin_node_add.kwargs = {'jail_id': jail.id }
plugin_node_add.model = 'Plugins'
plugin_node_add.icon = u'PluginInstallIcon'
plugin_node_add.app_name = 'jails'
plugin_node_add.order = plugin_order
plugin_node.append_child(plugin_node_add)
jail_node.append_child(plugin_node)