Skip to content

Commit bebd7c4

Browse files
authored
Highlight the Add tab on the new-sponsor page (#400)
The sponsorship rail always highlighted "Sponsors", even on the add-new-sponsor page. Make "Add sponsor" highlightable and mark it current on the create page; editing an existing sponsor still highlights "Sponsors".
1 parent c65119c commit bebd7c4

3 files changed

Lines changed: 39 additions & 2 deletions

File tree

sponsorship/templates/sponsorship/_sponsorship_rail.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,9 @@
2121
{% endif %}
2222
<hr class="my-2">
2323
{% url 'sponsorship:sponsorship_profile_new' as add_url %}
24-
{% include "portal/_sidebar_item.html" with url=add_url label=_("Add sponsor") icon="fa-plus" only %}
24+
{% if active == "add" %}
25+
{% include "portal/_sidebar_item.html" with url=add_url label=_("Add sponsor") icon="fa-plus" active=True only %}
26+
{% else %}
27+
{% include "portal/_sidebar_item.html" with url=add_url label=_("Add sponsor") icon="fa-plus" only %}
28+
{% endif %}
2529
{% endif %}

sponsorship/templates/sponsorship/sponsorship_profile_form.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
{% trans "Sponsorship" %}
2020
{% endblock sidebar_title %}
2121
{% block sidebar %}
22-
{% include "sponsorship/_sponsorship_rail.html" with active="sponsors" %}
22+
{% if object.pk %}
23+
{% include "sponsorship/_sponsorship_rail.html" with active="sponsors" %}
24+
{% else %}
25+
{% include "sponsorship/_sponsorship_rail.html" with active="add" %}
26+
{% endif %}
2327
{% endblock sidebar %}
2428
{% block content %}
2529
<main>

tests/sponsorship/test_views.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,35 @@ def test_top_nav_collapses_to_single_link(self, client, admin_user, conference):
192192
assert 'id="navSponsorship"' not in content # dropdown removed
193193
assert "Manage tiers" not in content # old dropdown item label gone
194194

195+
def test_add_sponsor_page_highlights_add(self, client, admin_user, conference):
196+
client.force_login(admin_user)
197+
content = client.get(
198+
reverse("sponsorship:sponsorship_profile_new")
199+
).content.decode()
200+
# The "Add sponsor" rail entry is current here, not "Sponsors".
201+
assert self._active_href(
202+
content, reverse("sponsorship:sponsorship_profile_new")
203+
)
204+
assert not self._active_href(content, reverse("sponsorship:sponsorship_list"))
205+
206+
def test_edit_sponsor_page_highlights_sponsors(
207+
self, client, admin_user, conference
208+
):
209+
sponsor = SponsorshipProfile.objects.create(
210+
organization_name="Acme",
211+
conference=conference,
212+
progress_status=SponsorshipProgressStatus.PAID,
213+
)
214+
client.force_login(admin_user)
215+
content = client.get(
216+
reverse("sponsorship:sponsorship_profile_edit", kwargs={"pk": sponsor.pk})
217+
).content.decode()
218+
# Editing an existing sponsor lives under "Sponsors", not "Add sponsor".
219+
assert self._active_href(content, reverse("sponsorship:sponsorship_list"))
220+
assert not self._active_href(
221+
content, reverse("sponsorship:sponsorship_profile_new")
222+
)
223+
195224

196225
@pytest.mark.django_db
197226
class TestSponsorshipViews:

0 commit comments

Comments
 (0)