Skip to content

Commit eb7d627

Browse files
authored
Merge pull request #1356 from makeabilitylab/awards-followup
Awards page polish: clean anchors, paper counts, name spacing; retire import_awards
2 parents 8618252 + ce577d8 commit eb7d627

5 files changed

Lines changed: 50 additions & 24 deletions

File tree

docker-entrypoint.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,6 @@ echo "4.8 Running 'python manage.py recompute_url_names' to de-collide historica
125125
echo "******************************************"
126126
python manage.py recompute_url_names
127127

128-
echo "****************** STEP 4.9/5: docker-entrypoint.sh ************************"
129-
echo "4.9 Running 'python manage.py import_awards' to backfill missing Awards (idempotent)"
130-
echo "******************************************"
131-
python manage.py import_awards
132-
133128
# echo "****************** STEP 4.3/5: docker-entrypoint.sh ************************"
134129
# echo "4.3 Running 'python manage.py rename_person_images' to rename person images"
135130
# echo "******************************************"

makeabilitylab/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@
8686
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
8787

8888
# Makeability Lab Global Variables, including Makeability Lab version
89-
ML_WEBSITE_VERSION = "2.14.0" # Keep this updated with each release and also change the short description below
90-
ML_WEBSITE_VERSION_DESCRIPTION = "Feature: redesigned Awards page. Each award now renders as a card with a category-specific visual anchor — recipient photo (student awards), project thumbnail (project awards), or a gold medal icon (faculty honors), with an optional uploaded emblem (new Award.badge field) overriding any of these — led by a prominent golden-orange year badge. A new idempotent import_awards management command (wired into docker-entrypoint.sh) backfills ~27 people/project/faculty awards mined from the news archive + CV that were missing from the Awards page, and corrects the mis-dated Facilitators' Choice (PrototypAR) entry. Paper awards stay on Publication.award; the one gap ('Playing on Hard Mode') is tracked in #1354. /awards/ added to the Pa11y scan set."
89+
ML_WEBSITE_VERSION = "2.14.1" # Keep this updated with each release and also change the short description below
90+
ML_WEBSITE_VERSION_DESCRIPTION = "Patch: Awards page polish. Section headings now use clean, shareable anchor IDs (e.g. #student-awards, #best-paper-awards instead of #section-...-heading); recipient/project lists no longer render a stray space before the comma ('Name, Project'); and the Best/Other Paper Award headings show a count, e.g. 'Best Paper Awards (12)'. Also retires the one-time import_awards step from the deploy sequence now that the backfill has run on test + prod — the management command stays in the repo (unwired, re-runnable) so a future rebuild can replay it."
9191
DATE_MAKEABILITYLAB_FORMED = datetime.date(2012, 1, 1) # Date Makeability Lab was formed
9292
MAX_BANNERS = 7 # Maximum number of banners on a page
9393

website/templates/snippets/display_award_snippet.html

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,11 @@ <h3 class="award-title">
5454

5555
{% if award.organization %}<p class="award-org">{{ award.organization }}</p>{% endif %}
5656

57+
{# Recipients, then publicly-visible projects (private ones omitted, #1300). The
58+
endfor/connector/for junctions are kept whitespace-tight on one line so the
59+
output reads "Name, Project" and never "Name , Project". #}
5760
<p class="award-recipients">
58-
{% for person in award.recipients.all %}<a href="{% url 'website:member_by_name' person.get_url_name %}">{{ person.get_full_name }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}
59-
60-
{% if award.recipients.exists and award.get_visible_projects.exists %}, {% endif %}
61-
62-
{# Only list publicly-visible projects so private projects aren't named here (#1300) #}
63-
{% for project in award.get_visible_projects %}<a href="{% url 'website:project' project.short_name %}">{{ project.name }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}
61+
{% for person in award.recipients.all %}<a href="{% url 'website:member_by_name' person.get_url_name %}">{{ person.get_full_name }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}{% if award.recipients.exists and award.get_visible_projects.exists %}, {% endif %}{% for project in award.get_visible_projects %}<a href="{% url 'website:project' project.short_name %}">{{ project.name }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}
6462
</p>
6563

6664
{% if award.description %}

website/templates/website/awards.html

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ <h1>Makeability Lab Awards</h1>
5151

5252
<!-- ===== People & project distinctions, sectioned by award_type ===== -->
5353
{% for section in distinction_sections %}
54-
<section aria-labelledby="section-{{ section.label|slugify }}-heading">
55-
<h2 id="section-{{ section.label|slugify }}-heading" class="heading-with-anchor">
54+
<section aria-labelledby="{{ section.label|slugify }}">
55+
<h2 id="{{ section.label|slugify }}" class="heading-with-anchor">
5656
{{ section.label }}
57-
<a href="#section-{{ section.label|slugify }}-heading" class="header-anchor"
57+
<a href="#{{ section.label|slugify }}" class="header-anchor"
5858
aria-label="Link to {{ section.label }} section">
5959
<i class="fa-solid fa-link" aria-hidden="true"></i>
6060
</a>
@@ -71,10 +71,10 @@ <h2 id="section-{{ section.label|slugify }}-heading" class="heading-with-anchor"
7171
{% endfor %}
7272

7373
<!-- ===== Best Paper Awards ===== -->
74-
<section aria-labelledby="best-paper-awards-heading">
75-
<h2 id="best-paper-awards-heading" class="heading-with-anchor">
76-
Best Paper Awards
77-
<a href="#best-paper-awards-heading" class="header-anchor"
74+
<section aria-labelledby="best-paper-awards">
75+
<h2 id="best-paper-awards" class="heading-with-anchor">
76+
Best Paper Awards ({{ best_paper_pubs|length }})
77+
<a href="#best-paper-awards" class="header-anchor"
7878
aria-label="Link to Best Paper Awards section">
7979
<i class="fa-solid fa-link" aria-hidden="true"></i>
8080
</a>
@@ -90,10 +90,10 @@ <h2 id="best-paper-awards-heading" class="heading-with-anchor">
9090
</section>
9191

9292
<!-- ===== Other Paper Awards ===== -->
93-
<section aria-labelledby="other-paper-awards-heading">
94-
<h2 id="other-paper-awards-heading" class="heading-with-anchor">
95-
Other Paper Awards
96-
<a href="#other-paper-awards-heading" class="header-anchor"
93+
<section aria-labelledby="other-paper-awards">
94+
<h2 id="other-paper-awards" class="heading-with-anchor">
95+
Other Paper Awards ({{ other_award_pubs|length }})
96+
<a href="#other-paper-awards" class="header-anchor"
9797
aria-label="Link to Other Paper Awards section">
9898
<i class="fa-solid fa-link" aria-hidden="true"></i>
9999
</a>

website/tests/test_award.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
than in a SimpleTestCase.
1212
"""
1313

14+
import re
1415
from datetime import date
1516

1617
from django.urls import reverse
@@ -115,3 +116,35 @@ def test_awards_page_renders_card_with_year_and_anchor_kind(self):
115116
self.assertIn("award-card", html)
116117
self.assertIn("award-card--medal", html) # faculty honor -> medal anchor
117118
self.assertIn("2017", html) # prominent year is rendered
119+
120+
def test_recipient_and_project_join_has_no_stray_space(self):
121+
# Regression: the recipient/project connector rendered as "Name , Project"
122+
# due to template whitespace between the two loops.
123+
person = self.make_person(first_name="Chu", last_name="Li")
124+
project = self.make_project(name="AltGeoViz", short_name="altgeoviz", is_visible=True)
125+
award = Award.objects.create(title="People's Choice Award", date=date(2024, 10, 29),
126+
award_type=AwardType.PROJECT_AWARD)
127+
award.recipients.set([person])
128+
award.projects.set([project])
129+
130+
html = self.client.get(reverse("website:awards")).content.decode()
131+
# Strip tags (names sit inside <a>…</a>), then collapse whitespace, so we
132+
# compare the *visible* text the way a reader sees it.
133+
text = re.sub(r"\s+", " ", re.sub(r"<[^>]+>", "", html))
134+
self.assertIn("Chu Li, AltGeoViz", text)
135+
self.assertNotIn("Chu Li , AltGeoViz", text)
136+
137+
def test_section_anchors_are_clean_and_paper_sections_show_counts(self):
138+
self.make_publication(title="A Great Paper", year=2020, award="Best Paper Award")
139+
Award.objects.create(title="A Faculty Honor", date=date(2017, 5, 1),
140+
award_type=AwardType.FACULTY_HONOR).recipients.set([self.make_person()])
141+
142+
html = self.client.get(reverse("website:awards")).content.decode()
143+
# Clean, shareable anchor IDs (no verbose 'section-...-heading').
144+
self.assertIn('id="faculty-honors"', html)
145+
self.assertIn('id="best-paper-awards"', html)
146+
self.assertNotIn("section-faculty-honors-heading", html)
147+
self.assertNotIn("best-paper-awards-heading", html)
148+
# Paper-section counts.
149+
self.assertIn("Best Paper Awards (1)", html)
150+
self.assertIn("Other Paper Awards (0)", html)

0 commit comments

Comments
 (0)