@@ -736,24 +736,35 @@ 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- html = "{% load thumbnail %}{% thumbnail sponsor.web_logo '150x150' format='PNG' quality=100 as im %}<img src='{{ im.url}}'/>{% endthumbnail %}"
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 %}"
740748 template = Template (html )
741- context = Context ({"sponsor" : obj .sponsor })
742- html = template .render (context )
743- return mark_safe (html ) # noqa: S308
749+ context = Context ({"img" : img })
750+ return mark_safe (template .render (context )) # noqa: S308
744751
745752 @admin .display (description = "Print Logo" )
746753 def get_sponsor_print_logo (self , obj ):
747754 """Render and return the sponsor's print logo as a thumbnail image."""
748755 img = obj .sponsor .print_logo
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 %}"
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 ,
753762 )
754- context = Context ({"img" : img })
755- html = mark_safe (template .render (context )) # noqa: S308
756- return html
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
757768
758769 @admin .display (description = "Primary Phone" )
759770 def get_sponsor_primary_phone (self , obj ):
@@ -807,7 +818,7 @@ def get_custom_benefits_added_by_user(self, obj):
807818 if not benefits :
808819 return "---"
809820
810- return format_html_join ("" , "<p>{}</p>" , benefits )
821+ return format_html_join ("" , "<p>{}</p>" , (( b ,) for b in benefits ) )
811822
812823 @admin .display (description = "Removed by User" )
813824 def get_custom_benefits_removed_by_user (self , obj ):
@@ -816,7 +827,7 @@ def get_custom_benefits_removed_by_user(self, obj):
816827 if not benefits :
817828 return "---"
818829
819- return format_html_join ("" , "<p>{}</p>" , benefits )
830+ return format_html_join ("" , "<p>{}</p>" , (( b ,) for b in benefits ) )
820831
821832 def rollback_to_editing_view (self , request , pk ):
822833 """Delegate to the rollback_to_editing admin view."""
@@ -1277,7 +1288,7 @@ def get_value(self, obj):
12771288 """Return the asset value, linking to the file URL if applicable."""
12781289 html = obj .value
12791290 if obj .value and getattr (obj .value , "url" , None ):
1280- html = format_html ("<a href='{}' target='_blank'>{}</a>" , ( obj .value .url , obj .value ) )
1291+ html = format_html ("<a href='{}' target='_blank'>{}</a>" , obj .value .url , obj .value )
12811292 return html
12821293
12831294 @admin .display (description = "Associated with" )
@@ -1289,9 +1300,9 @@ def get_related_object(self, obj):
12891300 """
12901301 content_object = None
12911302 if obj .from_sponsorship :
1292- content_object = self .all_sponsorships [ obj .object_id ]
1303+ content_object = self .all_sponsorships . get ( obj .object_id )
12931304 elif obj .from_sponsor :
1294- content_object = self .all_sponsors [ obj .object_id ]
1305+ content_object = self .all_sponsors . get ( obj .object_id )
12951306
12961307 if not content_object : # safety belt
12971308 return obj .content_object
0 commit comments