Skip to content

Commit 471b246

Browse files
committed
Replace tree_node.html include with inline Django 6.0 partialdef
The recursive tree_node.html file is folded into tree.html using {% partialdef tree_node %} / {% partial tree_node %}. Context is passed via {% with node=child %}, which works because PartialNode uses DeferredSubDict for runtime lookup, making recursive self-reference safe. https://claude.ai/code/session_01M6L96N8QWgnkDqGCYobb4d
1 parent 6f649c6 commit 471b246

2 files changed

Lines changed: 19 additions & 16 deletions

File tree

moderation/templates/moderation/tree.html

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@
33
{% block title %}Arbre de modération{% endblock %}
44

55
{% block content %}
6+
{% partialdef tree_node %}
7+
<li>
8+
<strong><a href="{% url 'moderation_profile' node.user.netid %}">{{ node.user.netid }}</a></strong>
9+
<span class="text-muted">{{ node.user.name }}</span>
10+
<span class="doc-count">({{ node.user.action_count }} action{{ node.user.action_count|pluralize }})</span>
11+
{% if node.user.is_staff %}
12+
<span class="badge bg-danger ms-1" style="font-size:0.7em;">Admin</span>
13+
{% endif %}
14+
{% if node.children %}
15+
<ul>
16+
{% for child in node.children %}
17+
{% with node=child %}{% partial tree_node %}{% endwith %}
18+
{% endfor %}
19+
</ul>
20+
{% endif %}
21+
</li>
22+
{% endpartialdef %}
23+
624
<div class="container-xl mt-4">
725
<nav aria-label="breadcrumb">
826
<ol class="breadcrumb">
@@ -65,7 +83,7 @@ <h1 class="h3 mb-4">Arbre de modération</h1>
6583
<div class="mod-tree">
6684
<ul class="tree-root">
6785
{% for root in tree %}
68-
{% include "moderation/tree_node.html" with node=root %}
86+
{% with node=root %}{% partial tree_node %}{% endwith %}
6987
{% endfor %}
7088
</ul>
7189
</div>

moderation/templates/moderation/tree_node.html

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)