Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from feincms3.apps import AppsMixin, reverse_app
from feincms3.mixins import (
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",
from __future__ import unicode_literals
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')),
@staticmethod
def fill_application_choices(sender, **kwargs):
"""
Fills in the choices for ``application`` from the ``APPLICATIONS``
class variable. This method is a receiver of Django's
``class_prepared`` signal.
"""
if issubclass(sender, AppsMixin) and not sender._meta.abstract:
sender._meta.get_field("application").choices = [
app[:2] for app in sender.APPLICATIONS
]
global _APPS_MODEL
_APPS_MODEL = sender
signals.class_prepared.connect(AppsMixin.fill_application_choices)
def fill_application_choices(sender, **kwargs):
"""
Fills in the choices for ``application`` from the ``APPLICATIONS``
class variable. This method is a receiver of Django's
``class_prepared`` signal.
"""
if issubclass(sender, AppsMixin) and not sender._meta.abstract:
sender._meta.get_field("application").choices = [
app[:2] for app in sender.APPLICATIONS
]
global _APPS_MODEL
_APPS_MODEL = sender