Add user content management views and templates for content review

This commit is contained in:
Ross
2026-02-13 22:26:41 +00:00
parent 2ab5a8e3b5
commit 19eb10c089
4 changed files with 184 additions and 0 deletions
@@ -0,0 +1,62 @@
{% load static %}
{% if user_obj %}
<div class="card p-2">
<h5>Content by {{ user_obj.get_full_name }} ({{ user_obj.username }})</h5>
{% for app_key, info in content.items %}
<div class="mb-2">
<strong>{{ info.label }}</strong>
<div class="small">
Questions: {{ info.questions|length }} &nbsp; Exams: {{ info.exams|length }}
</div>
<div class="mt-1">
{% if info.questions %}
<ul class="list-unstyled ms-3">
{% for q in info.questions %}
<li>
{% comment %} Try to link to app question detail if available {% endcomment %}
<a href="{% url app_key|add:':question_detail' q.pk %}" target="_blank">{{ q }}</a>
</li>
{% endfor %}
</ul>
{% endif %}
{% if info.exams %}
<ul class="list-unstyled ms-3">
{% for ex in info.exams %}
<li>{{ ex }}</li>
{% endfor %}
</ul>
{% endif %}
</div>
</div>
{% endfor %}
<div class="mb-2">
<strong>Atlas Cases</strong>
<div class="small">Cases: {{ atlas_cases|length }}</div>
{% if atlas_cases %}
<ul class="list-unstyled ms-3">
{% for case in atlas_cases %}
<li><a href="{% url 'atlas:case_detail' case.pk %}" target="_blank">{{ case }}</a></li>
{% endfor %}
</ul>
{% endif %}
</div>
<div class="mb-2">
<strong>Atlas Collections</strong>
<div class="small">Collections: {{ atlas_collections|length }}</div>
{% if atlas_collections %}
<ul class="list-unstyled ms-3">
{% for coll in atlas_collections %}
<li><a href="{% url 'atlas:collection_detail' coll.pk %}" target="_blank">{{ coll }}</a></li>
{% endfor %}
</ul>
{% endif %}
</div>
</div>
{% else %}
<div>No user found</div>
{% endif %}
@@ -0,0 +1,35 @@
{% extends 'generic/base.html' %}
{% block content %}
<h2>User content</h2>
<p>Click "Show content" to load items created by a user.</p>
<table class="table table-sm">
<thead>
<tr>
<th>Name</th>
<th>Username</th>
<th>Content count</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for user in users %}
<tr>
<td>{{ user.first_name }} {{ user.last_name }}</td>
<td><a href="{% url 'account_profile' user.username %}">{{ user.username }}</a></td>
<td>{{ user.content_count }}</td>
<td>
<button class="btn btn-sm btn-outline-primary"
hx-get="{% url 'generic:user_content_review' user.pk %}"
hx-target="closest tr"
hx-swap="afterend">Show content</button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}