Skip to content

Commit 5bfadd5

Browse files
committed
show document counts and warnings in tree & pending requests
1 parent 62db97c commit 5bfadd5

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

moderation/templates/moderation/moderators_management.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,17 @@ <h2 class="h5 mb-1">Demandes en attente</h2>
4949
<dd class="col-sm-9 small mb-0">{{ req.get_faculty_display }}</dd>
5050
<dt class="col-sm-3 text-muted fw-normal small">Rôle</dt>
5151
<dd class="col-sm-9 small mb-0">{{ req.get_role_display }}</dd>
52+
<dt class="col-sm-3 text-muted fw-normal small">Inscrit·e depuis</dt>
53+
<dd class="col-sm-9 small mb-0">{{ req.user.created|date:"d/m/Y" }} ({{ req.user.created|timesince }}){% if req.user.is_recent %} <span class="text-warning">⚠️ moins d'un mois</span>{% endif %}</dd>
54+
<dt class="col-sm-3 text-muted fw-normal small">Documents uploadés</dt>
55+
<dd class="col-sm-9 small mb-0">{{ req.user_document_count }}{% if req.user_document_count < 5 %} <span class="text-warning">⚠️ moins de 5 documents</span>{% endif %}</dd>
5256
{% if req.comment %}
5357
<dt class="col-sm-3 text-muted fw-normal small">Commentaire</dt>
5458
<dd class="col-sm-9 small mb-0 fst-italic">{{ req.comment }}</dd>
5559
{% endif %}
5660
</dl>
5761

62+
5863
<form method="post" action="{% url 'process_representative_request' req.id %}">
5964
{% csrf_token %}
6065
<div class="d-flex gap-2 flex-wrap">

moderation/views.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ def manage_moderators(request):
135135
pending_requests = (
136136
RepresentativeRequest.objects.filter(processed=False)
137137
.select_related("user")
138+
.annotate(user_document_count=Count("user__document"))
138139
.order_by("-created")
139140
)
140141
return render(

users/models.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import re
2+
from datetime import timedelta
23

34
from django.contrib.auth.models import AbstractBaseUser, UserManager
45
from django.db import models
@@ -58,6 +59,10 @@ class User(AbstractBaseUser):
5859
related_name="promoted_users",
5960
)
6061

62+
@property
63+
def is_recent(self):
64+
return timezone.now() - self.created < timedelta(days=30)
65+
6166
@property
6267
def name(self):
6368
return "{0.first_name} {0.last_name}".format(self)

0 commit comments

Comments
 (0)