parent
e5c075656c
commit
2cca0322d1
@ -1604,3 +1604,48 @@ label.required::after {
|
||||
margin-right: 1.2em;
|
||||
}
|
||||
}
|
||||
|
||||
.moderation_heatmap {
|
||||
border-spacing: 0.1em;
|
||||
border-collapse: separate;
|
||||
|
||||
max-width: 600px;
|
||||
margin: auto;
|
||||
th {
|
||||
font-size: 70%;
|
||||
text-align: center;
|
||||
}
|
||||
td {
|
||||
font-size: 60%;
|
||||
text-align: center;
|
||||
}
|
||||
tbody th {
|
||||
text-align: right;
|
||||
}
|
||||
.ratio {
|
||||
border-radius: var(--border-radius);
|
||||
padding: 0.2em;
|
||||
color: black;
|
||||
}
|
||||
.score_0 {
|
||||
background: rgb(0, 128, 0);
|
||||
}
|
||||
.score_1 {
|
||||
background: rgb(255, 255, 0);
|
||||
}
|
||||
.score_2 {
|
||||
background: rgb(255, 166, 0);
|
||||
}
|
||||
.score_3 {
|
||||
background: rgb(255, 0, 0);
|
||||
}
|
||||
.score_4 {
|
||||
background: rgb(128, 0, 128);
|
||||
color: white;
|
||||
}
|
||||
@media only screen and (max-width: 300px) {
|
||||
.ratio, .month, .label {
|
||||
font-size: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,13 +17,38 @@
|
||||
{% block content %}
|
||||
<div class="grid two-columns">
|
||||
<div id="contenu-principal">
|
||||
<div>
|
||||
<article>
|
||||
<header>
|
||||
<div class="slide-buttons">
|
||||
<a href="{% url 'moderate' %}" role="button">Modérer {% picto_from_name "check-square" %}</a>
|
||||
</div>
|
||||
<h2>Modération à venir</h2>
|
||||
</header>
|
||||
|
||||
<article>
|
||||
{% for w in nb_not_moderated %}
|
||||
<table class="moderation_heatmap">
|
||||
<thead>
|
||||
<th></th>
|
||||
{% for m in w %}
|
||||
<th>{{ m.start_day|date:"d" }}<span class="month"> {{ m.start_day|date:"M"|lower }}</span></th>
|
||||
{% endfor %}
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="label">reste à modérer</h>
|
||||
{% for m in w %}
|
||||
<td class="ratio score_{{ m.note }}">{{ m.not_moderated }} / {{ m.nb_events }}</td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{% endfor %}
|
||||
|
||||
</article>
|
||||
|
||||
<article>
|
||||
<header>
|
||||
<div class="slide-buttons">
|
||||
<a href="{% url 'moderate' %}" role="button">Modérer {% picto_from_name "check-square" %}</a>
|
||||
</div>
|
||||
|
||||
<h2>Activité des derniers jours</h2>
|
||||
</header>
|
||||
<h3>Résumé des activités</h3>
|
||||
@ -36,6 +61,7 @@
|
||||
{% include "agenda_culturel/rimports-info-inc.html" with all=1 %}</p>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<header>
|
||||
|
@ -76,7 +76,7 @@ from django.utils import timezone
|
||||
from django.utils.html import escape
|
||||
from datetime import date, timedelta
|
||||
from django.utils.timezone import datetime
|
||||
from django.db.models import Q, Subquery, OuterRef, Count, F, Func
|
||||
from django.db.models import Q, Subquery, OuterRef, Count, F, Func, BooleanField, ExpressionWrapper
|
||||
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
@ -873,9 +873,13 @@ def activite(request):
|
||||
@login_required(login_url="/accounts/login/")
|
||||
@permission_required("agenda_culturel.view_event")
|
||||
def administration(request):
|
||||
nb_mod_days = 21
|
||||
nb_classes = 4
|
||||
today = date.today()
|
||||
start_time = datetime.now().time()
|
||||
|
||||
# get information about recent modifications
|
||||
days = [date.today()]
|
||||
days = [today]
|
||||
for i in range(0, 2):
|
||||
days.append(days[-1] + timedelta(days=-1))
|
||||
daily_modifications = Event.get_count_modifications([(d, 1) for d in days])
|
||||
@ -905,13 +909,40 @@ def administration(request):
|
||||
.count())
|
||||
nb_all = imported_events.count()
|
||||
|
||||
window_end = today + timedelta(days=nb_mod_days)
|
||||
# get all non moderated events
|
||||
nb_not_moderated = Event.objects.filter(~Q(status=Event.STATUS.TRASH)). \
|
||||
filter(Q(start_day__gte=today)&Q(start_day__lte=window_end)). \
|
||||
filter(
|
||||
Q(other_versions__isnull=True) |
|
||||
Q(other_versions__representative=F('pk')) |
|
||||
Q(other_versions__representative__isnull=True)).values("start_day").\
|
||||
annotate(not_moderated=Count("start_day", filter=Q(moderated_date__isnull=True))). \
|
||||
annotate(nb_events=Count("start_day")). \
|
||||
order_by("start_day")
|
||||
|
||||
max_not_moderated = max([x["not_moderated"] for x in nb_not_moderated])
|
||||
if max_not_moderated == 0:
|
||||
max_not_moderated = 1
|
||||
nb_not_moderated_dict = dict([(x["start_day"], (x["not_moderated"], x["nb_events"])) for x in nb_not_moderated])
|
||||
# add missing dates
|
||||
date_list = [today + timedelta(days=x) for x in range(0, nb_mod_days)]
|
||||
nb_not_moderated = [{"start_day": d,
|
||||
"nb_events": nb_not_moderated_dict[d][1] if d in nb_not_moderated_dict else 0,
|
||||
"not_moderated": nb_not_moderated_dict[d][0] if d in nb_not_moderated_dict else 0} for d in date_list]
|
||||
nb_not_moderated = [ x | { "note": 0 if x["not_moderated"] == 0 else int((nb_classes - 1) * x["not_moderated"] / max_not_moderated) + 1 } for x in nb_not_moderated]
|
||||
nb_not_moderated = [nb_not_moderated[x:x + 7] for x in range(0, len(nb_not_moderated), 7)]
|
||||
|
||||
|
||||
|
||||
return render(
|
||||
request,
|
||||
"agenda_culturel/administration.html",
|
||||
{"daily_modifications": daily_modifications,
|
||||
"events": events, "batch_imports": batch_imports,
|
||||
"nb_failed": nb_failed, "nb_canceled": nb_canceled,
|
||||
"nb_running": nb_running, "nb_all": nb_all},
|
||||
"nb_running": nb_running, "nb_all": nb_all,
|
||||
"nb_not_moderated": nb_not_moderated},
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user