From 7deefdd11282423e7eb6ede0b930974299eaf407 Mon Sep 17 00:00:00 2001 From: amandine-sahl Date: Fri, 18 Aug 2023 15:52:21 +0200 Subject: [PATCH] Style media overview --- apptax/admin/admin_view.py | 35 +++++++++++-------- .../admin/templates/admin/details_taxref.html | 30 +++++++++------- apptax/taxonomie/models.py | 8 +++++ 3 files changed, 46 insertions(+), 27 deletions(-) diff --git a/apptax/admin/admin_view.py b/apptax/admin/admin_view.py index b90d5073..a715190a 100644 --- a/apptax/admin/admin_view.py +++ b/apptax/admin/admin_view.py @@ -431,6 +431,7 @@ def can_delete(self): form_ajax_refs = {"taxon": TaxrefAjaxModelLoader("taxon")} + column_exclude_list = ("url",) form_extra_fields = { "chemin": form.ImageUploadField( label="Image", @@ -442,22 +443,26 @@ def can_delete(self): ) } - def _list_thumbnail(view, context, model, name): - path = None - if model.chemin: - path = url_for( - "media", - filename=form.thumbgen_filename(model.chemin), - _external=True, - ) - elif model.url: - path = model.url + def _list_titre(view, context, model, name): + return markupsafe.Markup(model.titre) - if not path: - return - return markupsafe.Markup(f"") - - column_formatters = {"chemin": _list_thumbnail} + def _list_thumbnail(view, context, model, name): + # format html + html = "" + if model.types.nom_type_media in ("Photo", "Photo_principale"): + html = f""" + + Taxon image + + """ + elif model.types.nom_type_media in ("Audio"): + html = f"