当前位置: 首页>>代码示例>>Python>>正文


Python TreeNode.kwargs["mf"]方法代码示例

本文整理汇总了Python中freenasUI.freeadmin.tree.TreeNode.kwargs["mf"]方法的典型用法代码示例。如果您正苦于以下问题:Python TreeNode.kwargs["mf"]方法的具体用法?Python TreeNode.kwargs["mf"]怎么用?Python TreeNode.kwargs["mf"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在freenasUI.freeadmin.tree.TreeNode的用法示例。


在下文中一共展示了TreeNode.kwargs["mf"]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _generate_app

# 需要导入模块: from freenasUI.freeadmin.tree import TreeNode [as 别名]
# 或者: from freenasUI.freeadmin.tree.TreeNode import kwargs["mf"] [as 别名]

#.........这里部分代码省略.........
            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" % (model._meta.app_label, model._meta.model_name)
                    except:
                        navopt.view = "freeadmin_%s_%s_add" % (model._meta.app_label, model._meta.model_name)

                else:
                    navopt = TreeNode(str(model._meta.object_name))
                    navopt.name = model._meta.verbose_name_plural
                    navopt.model = c
                    navopt.app_name = app
                    navopt.order_child = False

                for key in model._admin.nav_extra.keys():
                    navopt.__setattr__(key, model._admin.nav_extra.get(key))
                if model._admin.icon_model is not None:
                    navopt.icon = model._admin.icon_model

                if model._admin.menu_child_of is not None:
                    childs_of.append((navopt, model))
                    reg = True
                else:
                    reg = self.register_option(navopt, nav)

                if reg and not navopt.type:

                    qs = model.objects.filter(**model._admin.object_filters).order_by("-id")
                    if qs.count() > 0:
                        if model._admin.object_num > 0:
                            qs = qs[: model._admin.object_num]
                        for e in qs:
                            subopt = TreeNode("Edit")
                            subopt.type = "editobject"
                            subopt.view = "freeadmin_%s_%s_edit" % (model._meta.app_label, model._meta.model_name)
                            if model._admin.icon_object is not None:
                                subopt.icon = model._admin.icon_object
                            subopt.model = c
                            subopt.app_name = app
                            subopt.kwargs = {"oid": e.id}
                            if model._admin.edit_modelform:
                                subopt.kwargs["mf"] = model._admin.edit_modelform
                            subopt.gname = e.id
                            try:
                                subopt.name = unicode(e)
                            except:
                                subopt.name = "Object"
                            navopt.append_child(subopt)

                    # Node to add an instance of model
                    subopt = TreeNode("Add")
                    subopt.name = _(u"Add %s") % model._meta.verbose_name
                    subopt.view = "freeadmin_%s_%s_add" % (model._meta.app_label, model._meta.model_name)
                    subopt.order = 500
                    subopt.type = "dialog"
                    if model._admin.icon_add is not None:
                        subopt.icon = model._admin.icon_add
                    subopt.model = c
                    subopt.app_name = app
                    self.register_option(subopt, navopt)

                    # Node to view all instances of model
                    subopt = TreeNode("View")
                    subopt.name = _(u"View %s") % (model._meta.verbose_name_plural,)
                    subopt.view = u"freeadmin_%s_%s_datagrid" % (model._meta.app_label, model._meta.model_name)
                    if model._admin.icon_view is not None:
                        subopt.icon = model._admin.icon_view
                    subopt.model = c
                    subopt.app_name = app
                    subopt.order = 501
                    subopt.type = "viewmodel"
                    self.register_option(subopt, navopt)
开发者ID:jgehrcke,项目名称:freenas,代码行数:104,代码来源:navtree.py


注:本文中的freenasUI.freeadmin.tree.TreeNode.kwargs["mf"]方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。