Skip to content

Commit 62db97c

Browse files
committed
Simplify the css of the moderation tree
1 parent 6f649c6 commit 62db97c

3 files changed

Lines changed: 21 additions & 57 deletions

File tree

moderation/templates/moderation/tree.html

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -17,55 +17,11 @@ <h1 class="h3 mb-4">Arbre de modération</h1>
1717
Chaque branche représente une chaîne de confiance.
1818
</p>
1919

20-
<style>
21-
.mod-tree ul {
22-
list-style: none;
23-
padding-left: 1.5rem;
24-
margin: 0;
25-
position: relative;
26-
}
27-
.mod-tree ul::before {
28-
content: '';
29-
position: absolute;
30-
left: 0.4rem;
31-
top: 0;
32-
bottom: 0.75rem;
33-
border-left: 1px solid #ccc;
34-
}
35-
.mod-tree li {
36-
position: relative;
37-
padding: 0.15rem 0;
38-
}
39-
.mod-tree li::before {
40-
content: '';
41-
position: absolute;
42-
left: -1.1rem;
43-
top: 0.75rem;
44-
width: 0.7rem;
45-
border-top: 1px solid #ccc;
46-
}
47-
.mod-tree .tree-root {
48-
list-style: none;
49-
padding: 0;
50-
margin: 0;
51-
}
52-
.mod-tree .tree-root::before {
53-
display: none;
54-
}
55-
.mod-tree .tree-root > li::before {
56-
display: none;
57-
}
58-
.mod-tree .doc-count {
59-
color: #888;
60-
font-size: 0.9em;
61-
}
62-
</style>
63-
6420
{% if tree %}
65-
<div class="mod-tree">
66-
<ul class="tree-root">
21+
<div>
22+
<ul class="list-unstyled ps-0 mb-0">
6723
{% for root in tree %}
68-
{% include "moderation/tree_node.html" with node=root %}
24+
{% include "moderation/tree_node.html" with node=root is_root=True %}
6925
{% endfor %}
7026
</ul>
7127
</div>

moderation/templates/moderation/tree_node.html

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
<li>
2-
<strong><a href="{% url 'moderation_profile' node.user.netid %}">{{ node.user.netid }}</a></strong>
3-
<span class="text-muted">{{ node.user.name }}</span>
4-
<span class="doc-count">({{ node.user.action_count }} action{{ node.user.action_count|pluralize }})</span>
5-
{% if node.user.is_staff %}
6-
<span class="badge bg-danger ms-1" style="font-size:0.7em;">Admin</span>
7-
{% endif %}
1+
<li class="py-1">
2+
<div class="d-flex flex-wrap align-items-baseline gap-1">
3+
{% if not is_root %}
4+
<span class="border-top flex-shrink-0 align-self-center" style="width: 1rem;"></span>
5+
{% endif %}
6+
<strong><a href="{% url 'moderation_profile' node.user.netid %}">{{ node.user.netid }}</a></strong>
7+
<span class="text-muted">{{ node.user.name }}</span>
8+
<span class="text-muted small">({{ node.user.action_count }} action{{ node.user.action_count|pluralize }} de modération, {{ node.user.document_count }} document{{ node.user.document_count|pluralize }})</span>
9+
{% if node.user.is_staff %}
10+
<span class="badge text-bg-danger ms-1">Admin</span>
11+
{% endif %}
12+
</div>
813
{% if node.children %}
9-
<ul>
14+
<ul class="list-unstyled border-start ps-0 ms-2 mb-0">
1015
{% for child in node.children %}
11-
{% include "moderation/tree_node.html" with node=child %}
16+
{% include "moderation/tree_node.html" with node=child is_root=False %}
1217
{% endfor %}
1318
</ul>
1419
{% endif %}

moderation/views.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,10 @@ def moderation_tree(request):
285285
moderators = (
286286
User.objects.filter(Q(is_staff=True) | Q(is_moderator=True))
287287
.select_related("promoted_by")
288-
.annotate(action_count=Count("moderationlog"))
288+
.annotate(
289+
action_count=Count("moderationlog", distinct=True),
290+
document_count=Count("document", distinct=True),
291+
)
289292
.order_by("first_name")
290293
)
291294

0 commit comments

Comments
 (0)