diff --git a/apps/sponsors/admin.py b/apps/sponsors/admin.py index 9bbda711b..e307276cc 100644 --- a/apps/sponsors/admin.py +++ b/apps/sponsors/admin.py @@ -736,35 +736,24 @@ def get_sponsor_landing_page_url(self, obj): @admin.display(description="Web Logo") def get_sponsor_web_logo(self, obj): """Render and return the sponsor's web logo as a thumbnail image.""" - img = obj.sponsor.web_logo - if not img: - return "---" - if img.name and img.name.lower().endswith(".svg"): - return format_html( - '', - img.url, - ) - html = "{% load thumbnail %}{% thumbnail img '150x150' format='PNG' quality=100 as im %}{% endthumbnail %}" + html = "{% load thumbnail %}{% thumbnail sponsor.web_logo '150x150' format='PNG' quality=100 as im %}{% endthumbnail %}" template = Template(html) - context = Context({"img": img}) - return mark_safe(template.render(context)) # noqa: S308 + context = Context({"sponsor": obj.sponsor}) + html = template.render(context) + return mark_safe(html) # noqa: S308 @admin.display(description="Print Logo") def get_sponsor_print_logo(self, obj): """Render and return the sponsor's print logo as a thumbnail image.""" img = obj.sponsor.print_logo - if not img: - return "---" - if img.name and img.name.lower().endswith(".svg"): - return format_html( - '', - img.url, + html = "---" + if img: + template = Template( + "{% load thumbnail %}{% thumbnail img '150x150' format='PNG' quality=100 as im %}{% endthumbnail %}" ) - template = Template( - "{% load thumbnail %}{% thumbnail img '150x150' format='PNG' quality=100 as im %}{% endthumbnail %}" - ) - context = Context({"img": img}) - return mark_safe(template.render(context)) # noqa: S308 + context = Context({"img": img}) + html = mark_safe(template.render(context)) # noqa: S308 + return html @admin.display(description="Primary Phone") def get_sponsor_primary_phone(self, obj): diff --git a/apps/sponsors/templates/sponsors/partials/sponsors-list.html b/apps/sponsors/templates/sponsors/partials/sponsors-list.html index d6e33d2bd..365feb4a5 100644 --- a/apps/sponsors/templates/sponsors/partials/sponsors-list.html +++ b/apps/sponsors/templates/sponsors/partials/sponsors-list.html @@ -10,18 +10,14 @@

Sponsors

Visionary sponsors help to host Python downloads.

{% for sponsorship in sponsorships %} + {% thumbnail sponsorship.sponsor.web_logo "x150" format="PNG" quality=100 as im %}
- {% if sponsorship.sponsor.web_logo.name|lower|slice:"-4:" == ".svg" %} - {{ sponsorship.sponsor.name }} logo - {% else %} - {% thumbnail sponsorship.sponsor.web_logo "x150" format="PNG" quality=100 as im %} {{ sponsorship.sponsor.name }} logo - {% endthumbnail %} - {% endif %}

{{ sponsorship.sponsor.name }}

+ {% endthumbnail %} {% endfor %}
{% endcache CACHED_DOWNLOAD_SPONSORS_LIST %} @@ -32,15 +28,11 @@

Sponsors

Job Board Sponsors

{% for sponsorship in sponsorships %} + {% thumbnail sponsorship.sponsor.web_logo "x100" format="PNG" quality=100 as im %}
- {% if sponsorship.sponsor.web_logo.name|lower|slice:"-4:" == ".svg" %} - {{ sponsorship.sponsor.name }} logo - {% else %} - {% thumbnail sponsorship.sponsor.web_logo "x100" format="PNG" quality=100 as im %} {{ sponsorship.sponsor.name }} logo - {% endthumbnail %} - {% endif %}
+ {% endthumbnail %} {% endfor %}
{% endcache CACHED_JOBS_SPONSORS_LIST %}