Skip to content

Commit

Permalink
Add has_logo field in list
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Oct 26, 2023
1 parent 0ce0aa2 commit 412a761
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lemarche/labels/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 4 additions & 0 deletions lemarche/labels/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 412a761

Please sign in to comment.