parent
89ab546b88
commit
af8c4cda5c
@ -639,6 +639,11 @@ nav .badge {
|
|||||||
border-radius: .5em;
|
border-radius: .5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nav .badge.error {
|
||||||
|
background: #b71c1c;
|
||||||
|
border-color: #cb1b1b;
|
||||||
|
}
|
||||||
|
|
||||||
form [role="button"], form button {
|
form [role="button"], form button {
|
||||||
margin: var(--spacing) 0 var(--spacing) 0;
|
margin: var(--spacing) 0 var(--spacing) 0;
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
{% load contactmessages_extra %}
|
{% load contactmessages_extra %}
|
||||||
{% load utils_extra %}
|
{% load utils_extra %}
|
||||||
{% load duplicated_extra %}
|
{% load duplicated_extra %}
|
||||||
|
{% load rimports_extra %}
|
||||||
<body>
|
<body>
|
||||||
<div id="main-nav">
|
<div id="main-nav">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
@ -46,6 +47,9 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
{% if perms.agenda_culturel.view_recurrentimport %}
|
||||||
|
{% show_badge_failed_rimports "bottom" %}
|
||||||
|
{% endif %}
|
||||||
{% if perms.agenda_culturel.change_event %}
|
{% if perms.agenda_culturel.change_event %}
|
||||||
{% show_badges_events "bottom" %}
|
{% show_badges_events "bottom" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
23
src/agenda_culturel/templatetags/rimports_extra.py
Normal file
23
src/agenda_culturel/templatetags/rimports_extra.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
from django import template
|
||||||
|
from django.utils.safestring import mark_safe
|
||||||
|
from django.urls import reverse_lazy
|
||||||
|
from django.template.defaultfilters import pluralize
|
||||||
|
from django.db.models import OuterRef, Subquery
|
||||||
|
|
||||||
|
|
||||||
|
from agenda_culturel.models import RecurrentImport, BatchImportation
|
||||||
|
|
||||||
|
from .utils_extra import picto_from_name
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
@register.simple_tag
|
||||||
|
def show_badge_failed_rimports(placement="top"):
|
||||||
|
newest = BatchImportation.objects.filter(recurrentImport=OuterRef("pk")).order_by("-created_date")
|
||||||
|
nb_failed = RecurrentImport.objects.annotate(last_run_status=Subquery(newest.values("status")[:1])).filter(last_run_status=BatchImportation.STATUS.FAILED).count()
|
||||||
|
|
||||||
|
|
||||||
|
if nb_failed != 0:
|
||||||
|
return mark_safe('<a href="' + reverse_lazy("recurrent_imports") + '" class="badge error" data-placement="' + placement + '" data-tooltip="' + str(nb_failed) + ' importation' + pluralize(nb_failed) + ' récurrente' + pluralize(nb_failed) + ' en erreur">' + picto_from_name("alert-triangle") + " " + str(nb_failed) + '</a>')
|
||||||
|
else:
|
||||||
|
return ""
|
Loading…
Reference in New Issue
Block a user