MAJ bouton relancer
This commit is contained in:
parent
f9038a03f4
commit
a2b6f8bf62
@ -15,7 +15,7 @@
|
||||
<header>
|
||||
<div class="slide-buttons">
|
||||
<a href="{% url 'run_all_rimports' %}" role="button">Exécuter tout {% picto_from_name "play-circle" %}</a>
|
||||
{% if has_failed_rimports %}
|
||||
{% if has_failed_import %}
|
||||
<a href="{% url 'run_all_rimports_failed' %}" role="button">Relancer les imports échoués {% picto_from_name "play-circle" %}</a>
|
||||
{% endif %}
|
||||
<a href="{% url 'add_rimport'%}" role="button">Ajouter {% picto_from_name "plus-circle" %}</a>
|
||||
|
@ -12,10 +12,6 @@ from .utils_extra import picto_from_name
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def has_failed_rimports():
|
||||
return BatchImportation.objects.filter(status=BatchImportation.STATUS.FAILED).count() != 0
|
||||
|
||||
@register.simple_tag
|
||||
def show_badge_failed_rimports(placement="top"):
|
||||
newest = BatchImportation.objects.filter(recurrentImport=OuterRef("pk")).order_by(
|
||||
|
@ -51,7 +51,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
|
||||
from django.db.models import Q, Subquery, OuterRef
|
||||
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
@ -1093,6 +1093,17 @@ def recurrent_imports(request):
|
||||
paginator = Paginator(RecurrentImport.objects.all().order_by("-pk"), 10)
|
||||
page = request.GET.get("page")
|
||||
|
||||
newest = BatchImportation.objects.filter(recurrentImport=OuterRef("pk")).order_by(
|
||||
"-created_date"
|
||||
)
|
||||
has_failed_import = nb_failed = (
|
||||
RecurrentImport.objects.annotate(
|
||||
last_run_status=Subquery(newest.values("status")[:1])
|
||||
)
|
||||
.filter(last_run_status=BatchImportation.STATUS.FAILED)
|
||||
.count()
|
||||
) > 0
|
||||
|
||||
try:
|
||||
response = paginator.page(page)
|
||||
except PageNotAnInteger:
|
||||
@ -1101,7 +1112,7 @@ def recurrent_imports(request):
|
||||
response = paginator.page(paginator.num_pages)
|
||||
|
||||
return render(
|
||||
request, "agenda_culturel/rimports.html", {"paginator_filter": response}
|
||||
request, "agenda_culturel/rimports.html", {"paginator_filter": response, "has_failed_import": has_failed_import}
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user