Skip to content

Commit e139fc0

Browse files
authored
Revert "fix sentry svg (#2967)" (#2968)
1 parent 19f99df commit e139fc0

File tree

2 files changed

+15
-34
lines changed

2 files changed

+15
-34
lines changed

apps/sponsors/admin.py

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -736,35 +736,24 @@ def get_sponsor_landing_page_url(self, obj):
736736
@admin.display(description="Web Logo")
737737
def get_sponsor_web_logo(self, obj):
738738
"""Render and return the sponsor's web logo as a thumbnail image."""
739-
img = obj.sponsor.web_logo
740-
if not img:
741-
return "---"
742-
if img.name and img.name.lower().endswith(".svg"):
743-
return format_html(
744-
'<img src="{}" style="max-width:150px;max-height:150px"/>',
745-
img.url,
746-
)
747-
html = "{% load thumbnail %}{% thumbnail img '150x150' format='PNG' quality=100 as im %}<img src='{{ im.url}}'/>{% endthumbnail %}"
739+
html = "{% load thumbnail %}{% thumbnail sponsor.web_logo '150x150' format='PNG' quality=100 as im %}<img src='{{ im.url}}'/>{% endthumbnail %}"
748740
template = Template(html)
749-
context = Context({"img": img})
750-
return mark_safe(template.render(context)) # noqa: S308
741+
context = Context({"sponsor": obj.sponsor})
742+
html = template.render(context)
743+
return mark_safe(html) # noqa: S308
751744

752745
@admin.display(description="Print Logo")
753746
def get_sponsor_print_logo(self, obj):
754747
"""Render and return the sponsor's print logo as a thumbnail image."""
755748
img = obj.sponsor.print_logo
756-
if not img:
757-
return "---"
758-
if img.name and img.name.lower().endswith(".svg"):
759-
return format_html(
760-
'<img src="{}" style="max-width:150px;max-height:150px"/>',
761-
img.url,
749+
html = "---"
750+
if img:
751+
template = Template(
752+
"{% load thumbnail %}{% thumbnail img '150x150' format='PNG' quality=100 as im %}<img src='{{ im.url}}'/>{% endthumbnail %}"
762753
)
763-
template = Template(
764-
"{% load thumbnail %}{% thumbnail img '150x150' format='PNG' quality=100 as im %}<img src='{{ im.url}}'/>{% endthumbnail %}"
765-
)
766-
context = Context({"img": img})
767-
return mark_safe(template.render(context)) # noqa: S308
754+
context = Context({"img": img})
755+
html = mark_safe(template.render(context)) # noqa: S308
756+
return html
768757

769758
@admin.display(description="Primary Phone")
770759
def get_sponsor_primary_phone(self, obj):

apps/sponsors/templates/sponsors/partials/sponsors-list.html

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,14 @@ <h2 class="widget-title" style="text-align: center;">Sponsors</h2>
1010
<p style="text-align: center;">Visionary sponsors help to host Python downloads.</p>
1111
<div style="display: grid; grid-gap: 2em; grid-template-columns: repeat(auto-fit, minmax(150px, 0fr)); align-items: center; justify-content: center; margin-top: 1.5em;">
1212
{% for sponsorship in sponsorships %}
13+
{% thumbnail sponsorship.sponsor.web_logo "x150" format="PNG" quality=100 as im %}
1314
<div style="text-align: center;">
1415
<a href="{{ sponsorship.sponsor.landing_page_url }}" rel="sponsored noopener" target="_blank" style="border-bottom: 0;">
15-
{% if sponsorship.sponsor.web_logo.name|lower|slice:"-4:" == ".svg" %}
16-
<img src="{{ sponsorship.sponsor.web_logo.url }}" alt="{{ sponsorship.sponsor.name }} logo" style="max-height:150px;max-width:150px;height:auto;width:auto;">
17-
{% else %}
18-
{% thumbnail sponsorship.sponsor.web_logo "x150" format="PNG" quality=100 as im %}
1916
<img src="{{ im.url }}" alt="{{ sponsorship.sponsor.name }} logo" style="max-height:150px;max-width:150px;height:auto;width:auto;">
20-
{% endthumbnail %}
21-
{% endif %}
2217
</a>
2318
<p style="margin-top: 0.5em; margin-bottom: 0; font-size: 0.875em; color: #4d4d4d;">{{ sponsorship.sponsor.name }}</p>
2419
</div>
20+
{% endthumbnail %}
2521
{% endfor %}
2622
</div>
2723
{% endcache CACHED_DOWNLOAD_SPONSORS_LIST %}
@@ -32,15 +28,11 @@ <h2 class="widget-title" style="text-align: center;">Sponsors</h2>
3228
<h3 class="widget-title">Job Board Sponsors</h3>
3329
<div style="display: grid; grid-gap: 1em; grid-template-columns: repeat(auto-fit, minmax(100px, 0fr)); grid-template-rows: repeat(1, minmax(50px, 0fr)); align-items: center; justify-content: center; margin-top: 1em;">
3430
{% for sponsorship in sponsorships %}
31+
{% thumbnail sponsorship.sponsor.web_logo "x100" format="PNG" quality=100 as im %}
3532
<div>
36-
{% if sponsorship.sponsor.web_logo.name|lower|slice:"-4:" == ".svg" %}
37-
<img src="{{ sponsorship.sponsor.web_logo.url }}" alt="{{ sponsorship.sponsor.name }} logo" style="max-height:100px;max-width:100px;height:auto;width:auto;">
38-
{% else %}
39-
{% thumbnail sponsorship.sponsor.web_logo "x100" format="PNG" quality=100 as im %}
4033
<img src="{{ im.url }}" alt="{{ sponsorship.sponsor.name }} logo" style="max-height:100px;max-width:100px;height:auto;width:auto;">
41-
{% endthumbnail %}
42-
{% endif %}
4334
</div>
35+
{% endthumbnail %}
4436
{% endfor %}
4537
</div>
4638
{% endcache CACHED_JOBS_SPONSORS_LIST %}

0 commit comments

Comments
 (0)