Commit e9142ea1 authored by Robert's avatar Robert

Add link to group conversations to breadcrumb, refs #640

parent c3837686
Pipeline #1517 passed with stage
in 2 minutes and 21 seconds
......@@ -2,6 +2,7 @@ import html
import json
import os
import random
from collections import namedtuple
import bleach as python_bleach
import html2text as python_html2text
......@@ -18,6 +19,8 @@ from django.utils import html as django_html, safestring
from markdown.extensions import toc
from core.assets import get_assets
Link = namedtuple('Link', 'text url')
register = template.Library()
......@@ -72,6 +75,11 @@ def nolinebreaks(value):
return ' '.join(str(value).split('\n'))
@register.filter
def link_to(text, url):
return Link(text=text, url=url)
@register.filter
def html2text(html, preset='mail'):
text_maker = python_html2text.HTML2Text()
......@@ -130,6 +138,8 @@ def breadcrumb(context, *args):
for arg in args[:-1]:
if isinstance(arg, str):
crumbs.append((arg, None))
elif isinstance(arg, Link):
crumbs.append(arg)
elif hasattr(arg, 'get_absolute_url_for_user'):
crumbs.append((str(arg), arg.get_absolute_url_for_user(context.get('user'))))
else:
......
......@@ -4,6 +4,14 @@
{% block menu %}{% menu 'conversation' association.entity %}{% endblock %}
{% block heading_title %}{% with title='Gespräch' %}{{ block.super }}{% endwith %}{% endblock %}
{% block breadcrumb %}
{% if association.entity.is_group %}
{% url 'group-conversations' association.entity.pk as group_conversation_url %}
{% breadcrumb association.entity 'Gespräche'|link_to:group_conversation_url association.container %}
{% else %}
{% breadcrumb association.entity association.container %}
{% endif %}
{% endblock %}
{% block content %}
{% has_perm 'conversations.reply' user association as can_reply %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment