本文整理汇总了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
示例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])
示例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)
示例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]
示例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)
示例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]
示例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]
示例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]
示例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]
示例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
]))
示例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
示例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
示例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
示例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))
示例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')