Пример #1
0
    def get_edit_handler(cls):
        """
        Get the EditHandler to use in the Wagtail admin when editing
        this page type.
        """

        if hasattr(cls, "edit_handler"):
            return cls.edit_handler.bind_to_model(cls)

        # construct a TabbedInterface made up of content_panels, promote_panels
        # and settings_panels, skipping any which are empty
        tabs = []

        if cls.content_panels:
            tabs.append(ObjectList(cls.content_panels, heading=_("Content")))

        if hasattr(cls, "extra_panels"):
            for panel_id, heading in cls.extra_panels:
                tabs.append(ObjectList(getattr(cls, panel_id), heading=heading))

        if cls.promote_panels:
            tabs.append(ObjectList(cls.promote_panels, heading=_("Promote")))

        if cls.settings_panels:
            tabs.append(
                ObjectList(
                    cls.settings_panels, heading=_("Settings"), classname="settings"
                )
            )

        EditHandler = TabbedInterface(tabs, base_form_class=cls.base_form_class)

        return EditHandler.bind_to_model(cls)
Пример #2
0
def get_edit_handler(cls):
    """
    Get the EditHandler to use in the Wagtail admin when editing this page type.
    """
    if hasattr(cls, 'edit_handler'):
        return cls.edit_handler.bind_to_model(cls)

    # construct a TabbedInterface made up of content_panels, promote_panels
    # and settings_panels, skipping any which are empty
    tabs = []

    if cls.content_panels:
        tabs.append(
            ObjectList(cls.content_panels, heading=ugettext_lazy('Content')))
    if cls.promote_panels:
        #MOD: Changed heading of `promote_panels` to `SEO`.
        tabs.append(
            ObjectList(cls.promote_panels, heading=ugettext_lazy('SEO')))
    if cls.settings_panels:
        tabs.append(
            ObjectList(cls.settings_panels,
                       heading=ugettext_lazy('Settings'),
                       classname="settings"))

    edit_handler = TabbedInterface(tabs, base_form_class=cls.base_form_class)
    return edit_handler.bind_to_model(cls)
Пример #3
0
 def get_edit_handler(cls):
     edit_handler = TabbedInterface([
         ObjectList(cls.content_panels, heading='Specific Page Content'),
         ObjectList(cls.page_panels, heading='Shared Page Attributes'),
         ObjectList(cls.promote_panels, heading='Promote'),
         ObjectList(cls.settings_panels,
                    heading='Settings',
                    classname="settings"),
     ])
     return edit_handler.bind_to_model(cls)
Пример #4
0
    def get_edit_handler(cls):
        if hasattr(cls, 'edit_handler'):
            return cls.edit_handler.bind_to_model(cls)

        edit_handler = TabbedInterface([
            ObjectList(cls.content_panels + [FieldPanel('author_notes')],
                       heading='Content'),
            ObjectList(Page.promote_panels + cls.promote_panels,
                       heading='Search Info')
        ])

        return edit_handler.bind_to_model(cls)
Пример #5
0
    def get_edit_handler(self):
        original_edit_handler = self.model.edit_handler

        # if self.instance.product_class and self.instance.product_class.name == 'Guitar':
        #     attributes_panels = [ StreamFieldPanel('guitar_attributes') ]
        # else:
        #     attributes_panels = self.model.attributes_panels

        attributes_panels = self.model.attributes_panels
        edit_handler = TabbedInterface([
            ObjectList(self.model.general_panels, heading='General'),
            ObjectList(attributes_panels, heading='Attributes'),
            ObjectList(self.model.images_panels, heading='Images'),
            ObjectList(self.model.categories_panels, heading='Categories'),
            ObjectList(self.model.settings_panels, heading='Settings'),
        ])
        return edit_handler.bind_to_model(self.model)
Пример #6
0
 def get_edit_handler_class(self):
     edit_handler = TabbedInterface([
         ObjectList(
             [
                 FieldPanel('name_en'),
                 FieldPanel('name_sv'),
                 FieldPanel('degree'),
             ],
             heading=_('General'),
         ),
         # TODO: http://stackoverflow.com/questions/43188124/
         # ObjectList([
         #     FieldPanel('sections', widget=CheckboxSelectMultiple),
         # ], heading=_('Sections'),
         # ),
     ])
     return edit_handler.bind_to_model(self.model)
Пример #7
0
 def get_edit_handler_class(self):
     edit_handler = TabbedInterface([
         ObjectList(
             [
                 FieldPanel('name_en'),
                 FieldPanel('name_sv'),
                 FieldPanel('abbreviation'),
             ],
             heading=_('General'),
         ),
         ObjectList(
             [
                 FieldPanel('studies', widget=CheckboxSelectMultiple),
             ],
             heading=_('Studies'),
         ),
     ])
     return edit_handler.bind_to_model(self.model)