Make ue comments a fragment

This commit is contained in:
2026-08-26 21:56:39 +02:00
parent 13829c0945
commit c84cef8e55
6 changed files with 63 additions and 29 deletions
@@ -6,13 +6,8 @@
{% endif %}
<form
hx-post="{{ action }}"
{% if form.is_creation %}
hx-target="#comments"
hx-swap="afterbegin"
{% else %}
hx-target="closest .leave-comment"
hx-swap="outerHTML"
{% endif %}
hx-target="closest .leave-comment"
hx-swap="outerHTML"
hx-disabled-elt="find input[type='submit']"
>
{% csrf_token %}
@@ -0,0 +1,17 @@
<section
hx-get="{{ url("pedagogy:ue_comments", ue_id=object.id) }}"
hx-swap="outerHTML"
hx-target="this"
hx-trigger="NewComment from:body"
>
{% if comments %}
<h2>{% trans %}Comments{% endtrans %}</h2>
<br>
{% endif %}
{% for comment in comments %}
{% include "pedagogy/fragments/ue_comment.jinja" %}
{% endfor %}
</section>
@@ -40,11 +40,6 @@
<br>
{% endif %}
{% if comments %}
<h2>{% trans %}Comments{% endtrans %}</h2>
<br>
{% endif %}
{% if not object.has_user_already_commented(user) and user.has_perm("pedagogy.add_uecomment") %}
{{ add_comment_form }}
{% endif %}
+1 -5
View File
@@ -61,11 +61,7 @@
{% include "pedagogy/fragments/ue_detail.jinja" %}
{% for comment in comments %}
<section id="comments">
{% include "pedagogy/fragments/ue_comment.jinja" %}
</section>
{% endfor %}
{{ comments }}
</div>
</div>