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


Python edit_handlers.extract_panel_definitions_from_model_class函数代码示例

本文整理汇总了Python中wagtail.wagtailadmin.edit_handlers.extract_panel_definitions_from_model_class函数的典型用法代码示例。如果您正苦于以下问题:Python extract_panel_definitions_from_model_class函数的具体用法?Python extract_panel_definitions_from_model_class怎么用?Python extract_panel_definitions_from_model_class使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: get_edit_handler_class

    def get_edit_handler_class(self):
        """
        Returns edit handler class for view model.

        :rtype: class.
        """
        # Custom class that skips adding missing fields, as we may want to
        # limit the number of fields presented to the user.
        class BaseChooserObjectList(BaseObjectList):
            def render_missing_fields(self):
                return ''
    
        def ChooserObjectList(children):
            return type('_ChooserObjectList', (BaseChooserObjectList,), {
                'children': children,
            })
    
        if hasattr(self.model, 'get_edit_handler'):
            handler_class = self.model.get_edit_handler()
        else:
            handler_class = ChooserObjectList(
                extract_panel_definitions_from_model_class(self.model)
            )

        # Return the edit handler class.
        return handler_class
开发者ID:MariusCC,项目名称:wagtailplus,代码行数:26,代码来源:crud.py

示例2: get_panel_definitions

 def get_panel_definitions(cls):
     # Look for a panels definition in the InlinePanel declaration
     if cls.panels is not None:
         return cls.panels
     # Failing that, get it from the model
     else:
         return extract_panel_definitions_from_model_class(cls.related.model, exclude=[cls.related.field.name])
开发者ID:taroved,项目名称:fk,代码行数:7,代码来源:edit_handlers.py

示例3: get_edit_handler_class

 def get_edit_handler_class(self):
     if hasattr(self.model, 'edit_handler'):
         edit_handler = self.model.edit_handler
     else:
         panels = extract_panel_definitions_from_model_class(self.model)
         edit_handler = ObjectList(panels)
     return edit_handler.bind_to_model(self.model)
开发者ID:potatolondon,项目名称:wagtail-gae,代码行数:7,代码来源:views.py

示例4: get_snippet_edit_handler

def get_snippet_edit_handler(model):
    if model not in SNIPPET_EDIT_HANDLERS:
        panels = extract_panel_definitions_from_model_class(model)
        edit_handler = ObjectList(panels).bind_to_model(model)

        SNIPPET_EDIT_HANDLERS[model] = edit_handler

    return SNIPPET_EDIT_HANDLERS[model]
开发者ID:niceguydave,项目名称:wagtail,代码行数:8,代码来源:snippets.py

示例5: get_edit_handler_class

 def get_edit_handler_class(self):
     if hasattr(self.model, 'edit_handler'):
         edit_handler = self.model.edit_handler
     else:
         fields_to_exclude = self.model_admin.get_form_fields_exclude(request=self.request)
         panels = extract_panel_definitions_from_model_class(self.model, exclude=fields_to_exclude)
         edit_handler = ObjectList(panels)
     return edit_handler.bind_to_model(self.model)
开发者ID:kapito,项目名称:wagtail,代码行数:8,代码来源:views.py

示例6: get_category_edit_handler

def get_category_edit_handler(model):
    if model not in CATEGORY_EDIT_HANDLERS:
        panels = extract_panel_definitions_from_model_class(model, ['site'])
        edit_handler = ObjectList(panels)

        CATEGORY_EDIT_HANDLERS[model] = edit_handler

    return CATEGORY_EDIT_HANDLERS[model]
开发者ID:salvadormrf,项目名称:wagtailcategories,代码行数:8,代码来源:views.py

示例7: get_setting_edit_handler

def get_setting_edit_handler(model):
    if model not in SETTING_EDIT_HANDLERS:
        panels = extract_panel_definitions_from_model_class(model, ['site'])
        edit_handler = ObjectList(panels).bind_to_model(model)

        SETTING_EDIT_HANDLERS[model] = edit_handler

    return SETTING_EDIT_HANDLERS[model]
开发者ID:click-ripple,项目名称:revolv,代码行数:8,代码来源:views.py

示例8: get_snippet_edit_handler

def get_snippet_edit_handler(model):
    if model not in SNIPPET_EDIT_HANDLERS:
        edit_handler = None
        try:
            edit_handler = model.get_edit_handler()
        except AttributeError:
            panels = extract_panel_definitions_from_model_class(model)
            edit_handler = ObjectList(panels)

        SNIPPET_EDIT_HANDLERS[model] = edit_handler

    return SNIPPET_EDIT_HANDLERS[model]
开发者ID:vlprans,项目名称:wagtail,代码行数:12,代码来源:snippets.py

示例9: get_snippet_edit_handler

def get_snippet_edit_handler(model):
    if model not in SNIPPET_EDIT_HANDLERS:
        if hasattr(model, 'edit_handler'):
            # use the edit handler specified on the page class
            edit_handler = model.edit_handler
        else:
            panels = extract_panel_definitions_from_model_class(model)
            edit_handler = ObjectList(panels)

        SNIPPET_EDIT_HANDLERS[model] = edit_handler.bind_to_model(model)

    return SNIPPET_EDIT_HANDLERS[model]
开发者ID:FannyFlores,项目名称:wagtail,代码行数:12,代码来源:snippets.py

示例10: test_can_build_panel_list

    def test_can_build_panel_list(self):
        # EventPage has no 'panels' definition, so one should be derived from the field list
        panels = extract_panel_definitions_from_model_class(EventPage)

        self.assertTrue(any([
            isinstance(panel, FieldPanel) and panel.field_name == 'date_from'
            for panel in panels
        ]))

        # returned panel types should respect modelfield.get_panel() - used on RichTextField
        self.assertTrue(any([
            isinstance(panel, RichTextFieldPanel) and panel.field_name == 'body'
            for panel in panels
        ]))
开发者ID:DjangoBD,项目名称:wagtail,代码行数:14,代码来源:test_edit_handlers.py

示例11: get_poll_edit_handler

def get_poll_edit_handler(Poll):
    panels = extract_panel_definitions_from_model_class(Poll)
    EditHandler = ObjectList(panels).bind_to_model(Poll)
    return EditHandler
开发者ID:takeflight,项目名称:wagtailpolls,代码行数:4,代码来源:editor.py

示例12: panel_perms

def panel_perms(Job, request):
    panels = extract_panel_definitions_from_model_class(
        Job, exclude=['jobindex'])
    EditHandler = ObjectList(panels).bind_to_model(Job)
    return EditHandler
开发者ID:SableWalnut,项目名称:wagtailjobs,代码行数:5,代码来源:panel_perms.py

示例13: get_invoice_edit_handler

def get_invoice_edit_handler(Invoice):
    panels = extract_panel_definitions_from_model_class(
        Invoice, exclude=['invoiceindex'])
    EditHandler = ObjectList(panels).bind_to_model(Invoice)
    return EditHandler
开发者ID:huxley,项目名称:wagtailinvoices,代码行数:5,代码来源:editor.py

示例14: test_extracted_objects_are_panels

 def test_extracted_objects_are_panels(self):
     panels = extract_panel_definitions_from_model_class(self.FakePage)
     for panel in panels:
         self.assertTrue(issubclass(panel, BaseFieldPanel))
开发者ID:0b3r,项目名称:wagtail,代码行数:4,代码来源:test_edit_handlers.py

示例15: test_can_extract_panels

 def test_can_extract_panels(self):
     mock = MagicMock()
     mock.panels = 'foo'
     result = extract_panel_definitions_from_model_class(mock)
     self.assertEqual(result, 'foo')
开发者ID:0b3r,项目名称:wagtail,代码行数:5,代码来源:test_edit_handlers.py


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