Browse Source

Some cleanup and comments.

master
Erik Stein 6 years ago
parent
commit
c8cc82aef4
  1. 3
      content_plugins/shortcuts.py
  2. 12
      content_plugins/templatetags/feincms3_helper_tags.py

3
content_plugins/shortcuts.py

@ -4,13 +4,13 @@ from django.http import HttpRequest
from django.template.loader import render_to_string
from django.utils.html import strip_tags
from content_editor.contents import contents_for_item
from shared.utils.text import html_entities_to_unicode
def render_page_as_html(page, template, context_data, css_selector=None):
request = HttpRequest()
request.user = AnonymousUser()
assert template, "No template supplied"
html = render_to_string(template, context_data, request=request)
if css_selector:
@ -24,6 +24,7 @@ def render_page_as_html(page, template, context_data, css_selector=None):
html = '\n'.join(html)
return html
def render_page_as_text(page, template, context_data, css_selector=None):
html = render_page_as_html(page, template, context_data, css_selector)
text = html_entities_to_unicode(strip_tags(html)).strip()

12
content_plugins/templatetags/feincms3_helper_tags.py

@ -12,11 +12,23 @@ from django.db.models import Q
register = template.Library()
"""
settings.py:
MENUMIXIN_MODELS = {
# class: [depth_from, depth_to, q_filters]
'projects.Project': [1, 1, None],
'site_pages.SitePage': [0, 1, (~Q(slug='frontpage'), Q(is_active=True))],
}
"""
MENUMIXIN_MODELS = getattr(settings, 'MENUMIXIN_MODELS', {})
@register.simple_tag
def menus():
# FIXME page.cte_path and page.path
menus = defaultdict(list)
def add_menus_from_model(model, depth_from=1, depth_to=1, q_filters=None):

Loading…
Cancel
Save