How to use the feincms3.mixins.TemplateMixin function in feincms3

To help you get started, we’ve selected a few feincms3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github matthiask / feincms3 / tests / testapp / models.py View on Github external
LanguageAndTranslationOfMixin,
    MenuMixin,
    RedirectMixin,
    TemplateMixin,
)
from feincms3.pages import AbstractPage
from feincms3.plugins import external, html, image, richtext, snippet


class Page(
    AbstractPage,
    # For adding the articles app to pages through the CMS:
    AppsMixin,
    # Two page templates, one with only a main region and another with a
    # sidebar as well:
    TemplateMixin,
    # We have a main and a footer navigation (meta):
    MenuMixin,
    # We're building a multilingual CMS. (Also, feincms3.apps depends on
    # LanguageMixin currently):
    LanguageAndTranslationOfMixin,
    # Allow redirecting pages to other pages and/or arbitrary URLs:
    RedirectMixin,
):

    # TemplateMixin
    TEMPLATES = [
        Template(
            key="standard",
            title=_("standard"),
            template_name="pages/standard.html",
            regions=(Region(key="main", title=_("Main")),),
github matthiask / feincms3 / feincms3 / mixins.py View on Github external
return self.template.regions if self.template else []

    @staticmethod
    def fill_template_key_choices(sender, **kwargs):
        """
        Fills in the choices for ``menu`` from the ``MENUS`` class variable.
        This method is a receiver of Django's ``class_prepared`` signal.
        """
        if issubclass(sender, TemplateMixin) and not sender._meta.abstract:
            field = sender._meta.get_field("template_key")
            field.choices = [(t.key, t.title) for t in sender.TEMPLATES]
            field.default = sender.TEMPLATES[0].key
            sender.TEMPLATES_DICT = {t.key: t for t in sender.TEMPLATES}


signals.class_prepared.connect(TemplateMixin.fill_template_key_choices)


class LanguageMixin(models.Model):
    """
    Pages may come in varying languages. ``LanguageMixin`` helps with that.
    """

    language_code = models.CharField(
        _("language"),
        max_length=10,
        choices=settings.LANGUAGES,
        default=settings.LANGUAGES[0][0],
    )

    class Meta:
        abstract = True
github matthiask / feincms3-example / app / pages / models.py View on Github external
from django.db import models
from django.utils.translation import gettext_lazy as _

from content_editor.models import Region, Template, create_plugin_base

from feincms3.apps import AppsMixin
from feincms3.mixins import TemplateMixin, MenuMixin, LanguageMixin
from feincms3.pages import AbstractPage
from feincms3.plugins import image, richtext


class Page(
    AbstractPage,
    AppsMixin,      # For adding the articles app to pages through the CMS.
    TemplateMixin,  # Two page templates, one with only a main
                    # region and another with a sidebar as well.
    MenuMixin,      # We have a main and a footer navigation (meta).
    LanguageMixin,  # We're building a multilingual CMS. (Also,
                    # feincms3.apps depends on LanguageMixin
                    # currently.)
):

    # TemplateMixin
    TEMPLATES = [
        Template(
            key='standard',
            title=_('standard'),
            template_name='pages/standard.html',
            regions=(
                Region(key='main', title=_('Main')),
            ),
github matthiask / feincms3 / feincms3 / mixins.py View on Github external
def fill_template_key_choices(sender, **kwargs):
        """
        Fills in the choices for ``menu`` from the ``MENUS`` class variable.
        This method is a receiver of Django's ``class_prepared`` signal.
        """
        if issubclass(sender, TemplateMixin) and not sender._meta.abstract:
            field = sender._meta.get_field("template_key")
            field.choices = [(t.key, t.title) for t in sender.TEMPLATES]
            field.default = sender.TEMPLATES[0].key
            sender.TEMPLATES_DICT = {t.key: t for t in sender.TEMPLATES}