refactor: replace format_html with mark_safe in admin models and fix translation string syntax in observation form template

This commit is contained in:
kdeterme 2026-08-07 09:28:22 +02:00
parent 297f51077e
commit 57367d825b
3 changed files with 3 additions and 3 deletions

View file

@ -231,7 +231,7 @@ class RequestLogAdmin(admin.ModelAdmin):
"""Affiche le nom d'utilisateur ou 'Anonyme'."""
if obj.username:
return obj.username
return format_html('<span style="color: #999; font-style: italic;">Anonyme</span>')
return mark_safe('<span style="color: #999; font-style: italic;">Anonyme</span>')
username_display.short_description = "Utilisateur"
username_display.admin_order_field = "username"

View file

@ -81,7 +81,7 @@ class HomeWidgetAdmin(admin.ModelAdmin):
)
parts.append(f'({label_html}{conditions} {order_badge})')
separator = format_html(' <span style="color: #D32F2F; font-weight: bold;">OU</span> ')
separator = mark_safe(' <span style="color: #D32F2F; font-weight: bold;">OU</span> ')
return mark_safe(separator.join(parts))
conditions_overview.short_description = 'Configuration'

View file

@ -2771,7 +2771,7 @@
xhr.addEventListener('error', function() {
loadingOverlay.style.display = 'none';
alert("{% translate \"Une erreur est survenue lors de l'envoi. Veuillez réessayer.\" %}");
alert("{% translate 'Une erreur est survenue lors de l\'envoi. Veuillez réessayer.' %}");
});
xhr.addEventListener('abort', function() {