From 0a3799cd7815f576a13969a8490d39635f26d547 Mon Sep 17 00:00:00 2001 From: Bernardo Fontes Date: Thu, 3 Feb 2022 16:21:08 -0300 Subject: [PATCH 1/5] Minimal working code to place sponsors logos --- templates/base.html | 5 +++++ templates/sponsors/partials/sponsors-list.html | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/templates/base.html b/templates/base.html index 385e80ff0..7cd423fbc 100644 --- a/templates/base.html +++ b/templates/base.html @@ -23,6 +23,11 @@ {# Kills IE6's images toolbar. Still useful. #} + {% stylesheet 'style' %} diff --git a/templates/sponsors/partials/sponsors-list.html b/templates/sponsors/partials/sponsors-list.html index e79b462e1..12d554113 100644 --- a/templates/sponsors/partials/sponsors-list.html +++ b/templates/sponsors/partials/sponsors-list.html @@ -44,6 +44,11 @@

{{ pa
{% for sponsorship in placement_info.sponsorships %} + {% if forloop.first %} +
+ {% endif %} + + {% comment %} + {% endcomment %} {% endfor %}
From b6c9bf8546771376c9b430cc67623351df0945f4 Mon Sep 17 00:00:00 2001 From: Bernardo Fontes Date: Thu, 10 Feb 2022 18:42:14 -0300 Subject: [PATCH 2/5] Replace thumbnail logo by EthicalAds integration --- .../sponsors/partials/sponsors-list.html | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/templates/sponsors/partials/sponsors-list.html b/templates/sponsors/partials/sponsors-list.html index 12d554113..960d9175e 100644 --- a/templates/sponsors/partials/sponsors-list.html +++ b/templates/sponsors/partials/sponsors-list.html @@ -38,32 +38,21 @@

Job Board Sponsors

{% if placement_info.sponsorships %}
{% with dimension=placement_info.logo_dimension %} - {% with thumbnail_res=dimension|add:"x"|add:dimension %}

{{ package }} Sponsors

{% for sponsorship in placement_info.sponsorships %} - {% if forloop.first %} -
- {% endif %} - - {% comment %} -
- {% endcomment %} +
{% endfor %}
{% endwith %} - {% endwith %}
{% endif %} {% endfor %} From eaf5dd15c7460ce9c9e525806864569b5269525f Mon Sep 17 00:00:00 2001 From: Bernardo Fontes Date: Thu, 10 Feb 2022 18:42:34 -0300 Subject: [PATCH 3/5] Create fallback to prevent 500 error when local development --- sponsors/templatetags/sponsors.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sponsors/templatetags/sponsors.py b/sponsors/templatetags/sponsors.py index 07bd63b0e..bb5a19481 100644 --- a/sponsors/templatetags/sponsors.py +++ b/sponsors/templatetags/sponsors.py @@ -76,6 +76,13 @@ def benefit_name_for_display(benefit, package): @register.filter def ideal_size(image, ideal_dimension): ideal_dimension = int(ideal_dimension) + try: + w, h = image.width, image.height + except FileNotFoundError: + # local dev doesn't have all images if DB is a copy from prod environment + # this is just a fallback to return ideal_dimension instead + w, h = ideal_dimension, ideal_dimension + return int( - image.width * math.sqrt((100 * ideal_dimension) / (image.width * image.height)) + w * math.sqrt((100 * ideal_dimension) / (w * h)) ) From ee7e9da8e3a2365f9ed168e6a4c68a201a450eeb Mon Sep 17 00:00:00 2001 From: Bernardo Fontes Date: Thu, 10 Feb 2022 18:48:31 -0300 Subject: [PATCH 4/5] Refactor by adding slug to sponsor model --- sponsors/models/sponsors.py | 5 +++++ templates/sponsors/partials/sponsors-list.html | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/sponsors/models/sponsors.py b/sponsors/models/sponsors.py index fad84d7dc..2bdf8aa9a 100644 --- a/sponsors/models/sponsors.py +++ b/sponsors/models/sponsors.py @@ -5,6 +5,7 @@ from django.conf import settings from django.db import models from django.core.exceptions import ObjectDoesNotExist +from django.template.defaultfilters import slugify from django_countries.fields import CountryField from ordered_model.models import OrderedModel from django.contrib.contenttypes.fields import GenericRelation @@ -102,6 +103,10 @@ def primary_contact(self): except SponsorContact.DoesNotExist: return None + @property + def slug(self): + return slugify(self.name) + class SponsorContact(models.Model): """ diff --git a/templates/sponsors/partials/sponsors-list.html b/templates/sponsors/partials/sponsors-list.html index 960d9175e..7f5cd1d15 100644 --- a/templates/sponsors/partials/sponsors-list.html +++ b/templates/sponsors/partials/sponsors-list.html @@ -46,7 +46,7 @@

{{ pa
{% endfor %} From ded5c6cb992f184489049f63539d3c83c7b54fa9 Mon Sep 17 00:00:00 2001 From: Ee Durbin Date: Mon, 14 Feb 2022 08:41:24 -0500 Subject: [PATCH 5/5] restore anchor link and sponsor name under logo on sponsors page --- templates/sponsors/partials/sponsors-list.html | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/templates/sponsors/partials/sponsors-list.html b/templates/sponsors/partials/sponsors-list.html index 7f5cd1d15..137ce0175 100644 --- a/templates/sponsors/partials/sponsors-list.html +++ b/templates/sponsors/partials/sponsors-list.html @@ -43,12 +43,15 @@

{{ pa
{% for sponsorship in placement_info.sponsorships %} -
+
+
+

{{ sponsorship.sponsor.name }}

+
{% endfor %}