diff --git a/lemarche/labels/admin.py b/lemarche/labels/admin.py index 1b49d1113..43707b121 100644 --- a/lemarche/labels/admin.py +++ b/lemarche/labels/admin.py @@ -10,12 +10,13 @@ @admin.register(Label, site=admin_site) class LabelAdmin(admin.ModelAdmin): - list_display = ["id", "name", "siae_count_annotated_with_link", "created_at"] + list_display = ["id", "name", "siae_count_annotated_with_link", "has_logo", "created_at"] search_fields = ["id", "name", "description"] search_help_text = "Cherche sur les champs : ID, Nom, Description" readonly_fields = [ "siae_count_annotated_with_link", + "has_logo", "logo_url_display", "data_last_sync_date", "logs_display", @@ -78,6 +79,12 @@ def get_prepopulated_fields(self, request, obj=None): return {"slug": ("name",)} return {} + def has_logo(self, instance): + return instance.has_logo + + has_logo.boolean = True + has_logo.short_description = "Logo ?" + def logo_url_display(self, instance): if instance.logo_url: return mark_safe( diff --git a/lemarche/labels/models.py b/lemarche/labels/models.py index 65ea850fe..71b693b91 100644 --- a/lemarche/labels/models.py +++ b/lemarche/labels/models.py @@ -44,3 +44,7 @@ def save(self, *args, **kwargs): """Generate the slug field before saving.""" self.set_slug() super().save(*args, **kwargs) + + @property + def has_logo(self): + return len(self.logo_url) > 0