Example #1
0
def get_page_edit_handler(page_class):
    if page_class not in PAGE_EDIT_HANDLERS:
        if hasattr(page_class, 'edit_handler'):
            # use the edit handler specified on the page class
            edit_handler = page_class.edit_handler
        else:
            # construct a TabbedInterface made up of content_panels, promote_panels
            # and settings_panels, skipping any which are empty
            tabs = []

            if page_class.content_panels:
                tabs.append(
                    ObjectList(page_class.content_panels,
                               heading=_('Content')))
            if page_class.promote_panels:
                tabs.append(
                    ObjectList(page_class.promote_panels,
                               heading=_('Promote')))
            if page_class.settings_panels:
                tabs.append(
                    ObjectList(page_class.settings_panels,
                               heading=_('Settings'),
                               classname="settings"))

            edit_handler = TabbedInterface(tabs)

        PAGE_EDIT_HANDLERS[page_class] = edit_handler.bind_to_model(page_class)

    return PAGE_EDIT_HANDLERS[page_class]
Example #2
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)
Example #3
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)
Example #4
0
    def get_edit_handler(self):
        """
        Get the EditHandler to use in the Wagtail admin when editing this page type.
        """
        if hasattr(self, 'edit_handler'):
            return self.edit_handler.bind_to_model(self)

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

        for tab in self.tabs:
            title, content, *args = tab
            kwargs = args[0] if args else {}
            tabs.append(ObjectList(content, heading=title, **kwargs))

        model = self._meta.model
        EditHandler = TabbedInterface(tabs,
                                      base_form_class=model.base_form_class)
        return EditHandler.bind_to_model(model)
def get_edit_handler(cls):
    """Add additional edit handlers to pages that are allowed to have
    variations.

    """
    tabs = []
    if cls.content_panels:
        tabs.append(ObjectList(cls.content_panels, heading=_("Content")))
    if cls.variation_panels:
        tabs.append(ObjectList(cls.variation_panels, heading=_("Variations")))
    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'))

    edit_handler = TabbedInterface(tabs, base_form_class=cls.base_form_class)
    return edit_handler.bind_to_model(cls)
Example #6
0
def get_page_edit_handler(page_class):
    if page_class not in PAGE_EDIT_HANDLERS:
        if hasattr(page_class, 'edit_handler'):
            # use the edit handler specified on the page class
            edit_handler = page_class.edit_handler
        else:
            # construct a TabbedInterface made up of content_panels, promote_panels
            # and settings_panels, skipping any which are empty
            tabs = []

            if page_class.content_panels:
                tabs.append(ObjectList(page_class.content_panels, heading=_('Content')))
            if page_class.promote_panels:
                tabs.append(ObjectList(page_class.promote_panels, heading=_('Promote')))
            if page_class.settings_panels:
                tabs.append(ObjectList(page_class.settings_panels, heading=_('Settings'), classname="settings"))

            edit_handler = TabbedInterface(tabs)

        PAGE_EDIT_HANDLERS[page_class] = edit_handler.bind_to_model(page_class)

    return PAGE_EDIT_HANDLERS[page_class]
Example #7
-1
    def get_edit_handler(self):
        """
        Get the EditHandler to use in the Wagtail admin when editing this page type.
        """
        if hasattr(self, 'edit_handler'):
            return self.edit_handler.bind_to_model(self)

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

        for tab in self.tabs:
            title, content, *args = tab
            kwargs = args[0] if args else {}
            tabs.append(ObjectList(content, heading=title, **kwargs))

        model = self._meta.model
        EditHandler = TabbedInterface(tabs,
                                      base_form_class=model.base_form_class)
        return EditHandler.bind_to_model(model)