Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
),
(
"translated-articles",
_("translated articles"),
{"urlconf": "testapp.translated_articles_urls"},
),
]
optional = models.IntegerField(blank=True, null=True)
not_editable = models.IntegerField(blank=True, null=True, editable=False)
PagePlugin = create_plugin_base(Page)
class RichText(richtext.RichText, PagePlugin):
pass
class Image(image.Image, PagePlugin):
caption = models.CharField(_("caption"), max_length=200, blank=True)
class Snippet(snippet.Snippet, PagePlugin):
TEMPLATES = [
(
"snippet.html",
_("snippet"),
lambda plugin, context: {"plugin": plugin, "additional": "context"},
)
]
from django.shortcuts import get_object_or_404, redirect, render
from feincms3.plugins import external, html, richtext
from feincms3.regions import Regions
from feincms3.renderer import TemplatePluginRenderer
from .models import HTML, External, Image, Page, RichText, Snippet
renderer = TemplatePluginRenderer()
renderer.register_string_renderer(RichText, richtext.render_richtext)
renderer.register_template_renderer(Image, "renderer/image.html")
Snippet.register_with(renderer)
renderer.register_string_renderer(External, external.render_external)
renderer.register_string_renderer(HTML, html.render_html)
def page_detail(request, path=None):
page = get_object_or_404(
Page.objects.active(), path=("/%s/" % path) if path else "/"
)
page.activate_language(request)
if page.redirect_to_url or page.redirect_to_page:
return redirect(page.redirect_to_url or page.redirect_to_page)
return render(
# article categories exactly for URL reversing and filtering articles by
# app to work! (See app.articles.models.Article.CATEGORIES)
APPLICATIONS = [
('publications', _('publications'), {
'urlconf': 'app.articles.urls',
}),
('blog', _('blog'), {
'urlconf': 'app.articles.urls',
}),
]
PagePlugin = create_plugin_base(Page)
class RichText(richtext.RichText, PagePlugin):
pass
class Image(image.Image, PagePlugin):
caption = models.CharField(
_('caption'),
max_length=200,
blank=True,
)