Test description
diff --git a/lacommunaute/forum/forms.py b/lacommunaute/forum/forms.py index 24e6ee178..268ba8810 100644 --- a/lacommunaute/forum/forms.py +++ b/lacommunaute/forum/forms.py @@ -5,7 +5,6 @@ from lacommunaute.forum.models import Forum from lacommunaute.partner.models import Partner -from lacommunaute.utils.html import wrap_iframe_in_div_tag class ForumForm(forms.ModelForm): @@ -45,7 +44,6 @@ def __init__(self, *args, **kwargs): def save(self, commit=True): forum = super().save(commit=False) - forum.description = wrap_iframe_in_div_tag(self.cleaned_data.get("description")) if commit: forum.save() diff --git a/lacommunaute/forum/tests/__snapshots__/tests_views.ambr b/lacommunaute/forum/tests/__snapshots__/tests_views.ambr index 997623353..18b4e423e 100644 --- a/lacommunaute/forum/tests/__snapshots__/tests_views.ambr +++ b/lacommunaute/forum/tests/__snapshots__/tests_views.ambr @@ -206,7 +206,13 @@
Test description
Test description
+ + +Text
\n\n\n\n" - "text
\n\n\n\nbye
" - ) - - def test_form_field(): form = ForumForm() assert form.Meta.model == Forum diff --git a/lacommunaute/forum_conversation/views_htmx.py b/lacommunaute/forum_conversation/views_htmx.py index d17cfb0b6..ff228a532 100644 --- a/lacommunaute/forum_conversation/views_htmx.py +++ b/lacommunaute/forum_conversation/views_htmx.py @@ -19,7 +19,7 @@ class TopicContentView(PermissionRequiredMixin, View): - template = "forum_conversation/partials/topic_content.html" + template = "partials/rendered_md.html" permission_required = [ "can_read_forum", ] @@ -32,6 +32,9 @@ def get_topic(self): ) return self.topic + def get_content(self): + return self.get_topic().first_post.content + def get(self, request, **kwargs): topic = self.get_topic() @@ -40,7 +43,7 @@ def get(self, request, **kwargs): return render( request, self.template, - context={"topic": topic}, + context={"content": self.get_content()}, ) def get_controlled_object(self): @@ -48,7 +51,8 @@ def get_controlled_object(self): class TopicCertifiedPostView(TopicContentView): - template = "forum_conversation/partials/topic_certified_post.html" + def get_content(self): + return self.get_topic().certified_post.post.content class PostListView(PermissionRequiredMixin, View): diff --git a/lacommunaute/partner/forms.py b/lacommunaute/partner/forms.py index e3aae2f5e..6b45bc314 100644 --- a/lacommunaute/partner/forms.py +++ b/lacommunaute/partner/forms.py @@ -2,7 +2,6 @@ from django.conf import settings from lacommunaute.partner.models import Partner -from lacommunaute.utils.html import wrap_iframe_in_div_tag class PartnerForm(forms.ModelForm): @@ -12,15 +11,6 @@ class PartnerForm(forms.ModelForm): widget=forms.FileInput(attrs={"accept": settings.SUPPORTED_IMAGE_FILE_TYPES.keys()}), ) - def save(self, commit=True): - partner = super().save(commit=False) - partner.description = wrap_iframe_in_div_tag(self.cleaned_data.get("description")) - - if commit: - partner.save() - - return partner - class Meta: model = Partner fields = ("name", "short_description", "description", "logo", "url") diff --git a/lacommunaute/partner/tests/__snapshots__/tests_partner_detailview.ambr b/lacommunaute/partner/tests/__snapshots__/tests_partner_detailview.ambr index 53ad13619..7b873c028 100644 --- a/lacommunaute/partner/tests/__snapshots__/tests_partner_detailview.ambr +++ b/lacommunaute/partner/tests/__snapshots__/tests_partner_detailview.ambr @@ -41,9 +41,15 @@lorem ipsum dolor sit amet, consectetur adipiscing elit.
+ -lorem ipsum dolor sit amet, consectetur adipiscing elit.
lorem ipsum dolor sit amet, consectetur adipiscing elit.
+ -lorem ipsum dolor sit amet, consectetur adipiscing elit.
lorem ipsum dolor sit amet, consectetur adipiscing elit.
+ -lorem ipsum dolor sit amet, consectetur adipiscing elit.
lorem ipsum dolor sit amet, consectetur adipiscing elit.
+ -lorem ipsum dolor sit amet, consectetur adipiscing elit.
Text
\n\n\n\n" - "text
\n\n\n\nbye
" - ) - - def test_form_field(): form = PartnerForm() assert form.Meta.model == Partner diff --git a/lacommunaute/partner/tests/tests_partner_createview.py b/lacommunaute/partner/tests/tests_partner_createview.py index e7ce8a435..876d7ff9d 100644 --- a/lacommunaute/partner/tests/tests_partner_createview.py +++ b/lacommunaute/partner/tests/tests_partner_createview.py @@ -39,7 +39,7 @@ def test_post_partner(client, db, url, superuser): data = { "name": "Test", "short_description": "Short description", - "description": "# Titre\n", + "description": "# Titre\ntext", "url": "https://www.example.com", } response = client.post(url, data) @@ -47,4 +47,4 @@ def test_post_partner(client, db, url, superuser): partner = Partner.objects.get() assert response.url == reverse("partner:detail", kwargs={"pk": partner.pk, "slug": partner.slug}) - assert partner.description.raw == "# Titre\n" + assert partner.description.raw == "# Titre\ntext" diff --git a/lacommunaute/templates/forum/forum_detail.html b/lacommunaute/templates/forum/forum_detail.html index c9c20a5c8..cec82303c 100644 --- a/lacommunaute/templates/forum/forum_detail.html +++ b/lacommunaute/templates/forum/forum_detail.html @@ -5,7 +5,6 @@ {% load forum_conversation_tags %} {% load forum_permission_tags %} {% load forum_tracking_tags %} -{% load str_filters %} {% block title %}{{ forum.name }}{{ block.super }}{% endblock %} {% block meta_description %} {{ forum.short_description }} @@ -34,7 +33,9 @@{{ post_form.subject.value }}
{% endif %} - {{ post_form.content.value|safe|rendered|urlizetrunc_target_blank:30 }} -