Skip to content

Revert "fix sentry svg (#2967)"#2968

Merged
JacobCoffee merged 1 commit intomainfrom
revert-2967-fix-spons-errs
Mar 21, 2026
Merged

Revert "fix sentry svg (#2967)"#2968
JacobCoffee merged 1 commit intomainfrom
revert-2967-fix-spons-errs

Conversation

@JacobCoffee
Copy link
Member

This reverts commit 258104a.

Copilot AI review requested due to automatic review settings March 21, 2026 00:18
@JacobCoffee JacobCoffee merged commit e139fc0 into main Mar 21, 2026
13 of 14 checks passed
@JacobCoffee JacobCoffee deleted the revert-2967-fix-spons-errs branch March 21, 2026 00:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reverts a prior change that added special handling for SVG sponsor logos, restoring the previous behavior of always generating PNG thumbnails via sorl-thumbnail.

Changes:

  • Remove SVG-specific branching in the public sponsors list partial and always render thumbnails for web_logo.
  • Remove SVG-specific branching in the Django admin logo renderers and revert to template-based thumbnail rendering.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
apps/sponsors/templates/sponsors/partials/sponsors-list.html Reverts conditional SVG rendering; always uses {% thumbnail %} for sponsor web_logo images.
apps/sponsors/admin.py Reverts SVG bypass logic in admin logo display methods; returns to thumbnail-based rendering for logos.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +739 to +743
html = "{% load thumbnail %}{% thumbnail sponsor.web_logo '150x150' format='PNG' quality=100 as im %}<img src='{{ im.url}}'/>{% 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
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_sponsor_web_logo now always renders a {% thumbnail sponsor.web_logo %} block without guarding for empty/missing files. In this codebase, Sponsor instances can exist without an actual web_logo file (e.g., tests use model_bakery without _create_files=True), which will cause sorl-thumbnail to raise and break the admin changelist/detail rendering. Add an early return (e.g., "---") when obj.sponsor.web_logo is falsy, or otherwise handle missing files before invoking thumbnail.

Copilot uses AI. Check for mistakes.
Comment on lines 748 to +756
img = obj.sponsor.print_logo
if not img:
return "---"
if img.name and img.name.lower().endswith(".svg"):
return format_html(
'<img src="{}" style="max-width:150px;max-height:150px"/>',
img.url,
html = "---"
if img:
template = Template(
"{% load thumbnail %}{% thumbnail img '150x150' format='PNG' quality=100 as im %}<img src='{{ im.url}}'/>{% endthumbnail %}"
)
template = Template(
"{% load thumbnail %}{% thumbnail img '150x150' format='PNG' quality=100 as im %}<img src='{{ im.url}}'/>{% 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
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_sponsor_print_logo thumbnails obj.sponsor.print_logo, but print_logo explicitly allows svg and eps/epsfepsi uploads. With only Pillow/sorl-thumbnail configured, SVG/EPS inputs will fail thumbnail generation and can crash the admin page. Handle non-raster formats explicitly (e.g., render SVG via direct <img src=...> or provide a download link; skip thumbnailing for EPS), and only call {% thumbnail %} for raster images like PNG/JPG.

Copilot uses AI. Check for mistakes.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a943b6d6bb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +751 to 753
template = Template(
"{% load thumbnail %}{% thumbnail img '150x150' format='PNG' quality=100 as im %}<img src='{{ im.url}}'/>{% endthumbnail %}"
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore SVG passthrough for print logos in admin

Sponsors can still upload SVG print logos (apps/sponsors/models/sponsors.py:52-59, and apps/sponsors/tests/test_forms.py:427-440 covers that path), but this revert now sends every non-empty print_logo through {% thumbnail ... format='PNG' %} again. That removes the only SVG bypass, so opening the sponsorship admin views for any sponsor using the documented SVG format can reproduce the original Sentry failure instead of rendering the uploaded file.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants