-
-
Notifications
You must be signed in to change notification settings - Fork 671
Revert "fix sentry svg (#2967)" #2968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 src="{}" style="max-width:150px;max-height:150px"/>', | ||
| img.url, | ||
| ) | ||
| html = "{% load thumbnail %}{% thumbnail img '150x150' format='PNG' quality=100 as im %}<img src='{{ im.url}}'/>{% endthumbnail %}" | ||
| 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 | ||
|
|
||
| @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 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 %}" | ||
| ) | ||
|
Comment on lines
+751
to
753
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sponsors can still upload SVG print logos ( Useful? React with 👍 / 👎. |
||
| 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 | ||
|
Comment on lines
748
to
+756
|
||
|
|
||
| @admin.display(description="Primary Phone") | ||
| def get_sponsor_primary_phone(self, obj): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_sponsor_web_logonow always renders a{% thumbnail sponsor.web_logo %}block without guarding for empty/missing files. In this codebase,Sponsorinstances can exist without an actualweb_logofile (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., "---") whenobj.sponsor.web_logois falsy, or otherwise handle missing files before invokingthumbnail.