Skip to content

Commit

Permalink
apply: make table view the default for prescribers
Browse files Browse the repository at this point in the history
  • Loading branch information
xavfernandez committed Jan 30, 2025
1 parent b77cebe commit 218a544
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
2 changes: 1 addition & 1 deletion itou/www/apply/views/list_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def list_prescriptions(request, template_name="apply/list_prescriptions.html"):
try:
display_kind = JobApplicationsDisplayKind(request.GET.get("display"))
except ValueError:
display_kind = JobApplicationsDisplayKind.LIST
display_kind = JobApplicationsDisplayKind.TABLE

context = {
"title": title,
Expand Down
12 changes: 6 additions & 6 deletions tests/www/apply/__snapshots__/test_list.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@


chez
<a class="btn-ico btn-link" href="/company/42/card?back_url=/apply/prescriptions/list">
<a class="btn-ico btn-link" href="/company/42/card?back_url=/apply/prescriptions/list%3Fdisplay%3Dlist">
<i aria-hidden="true" class="ri-community-line fw-medium ri-sm me-1"></i>
<span>Hit pit</span>
</a>
Expand Down Expand Up @@ -298,7 +298,7 @@
<div class="d-flex flex-column flex-md-row justify-content-md-end align-items-md-center gap-3">


<a aria-label="Gérer la candidature de J… H…" class="btn btn-outline-primary btn-block w-100 w-md-auto" data-matomo-action="clic" data-matomo-category="candidature" data-matomo-event="true" data-matomo-option="voir_candidature_prescripteur" href="/apply/11111111-1111-1111-1111-111111111111/prescriber/details?back_url=/apply/prescriptions/list">Voir sa candidature</a>
<a aria-label="Gérer la candidature de J… H…" class="btn btn-outline-primary btn-block w-100 w-md-auto" data-matomo-action="clic" data-matomo-category="candidature" data-matomo-event="true" data-matomo-option="voir_candidature_prescripteur" href="/apply/11111111-1111-1111-1111-111111111111/prescriber/details?back_url=/apply/prescriptions/list%3Fdisplay%3Dlist">Voir sa candidature</a>

</div>
</div>
Expand All @@ -321,7 +321,7 @@


chez
<a class="btn-ico btn-link" href="/company/42/card?back_url=/apply/prescriptions/list">
<a class="btn-ico btn-link" href="/company/42/card?back_url=/apply/prescriptions/list%3Fdisplay%3Dlist">
<i aria-hidden="true" class="ri-community-line fw-medium ri-sm me-1"></i>
<span>Hit pit</span>
</a>
Expand Down Expand Up @@ -380,7 +380,7 @@
</p>


<a aria-label="Gérer la candidature de J… H…" class="btn btn-outline-primary btn-block w-100 w-md-auto" data-matomo-action="clic" data-matomo-category="candidature" data-matomo-event="true" data-matomo-option="voir_candidature_prescripteur" href="/apply/22222222-2222-2222-2222-222222222222/prescriber/details?back_url=/apply/prescriptions/list">Voir sa candidature</a>
<a aria-label="Gérer la candidature de J… H…" class="btn btn-outline-primary btn-block w-100 w-md-auto" data-matomo-action="clic" data-matomo-category="candidature" data-matomo-event="true" data-matomo-option="voir_candidature_prescripteur" href="/apply/22222222-2222-2222-2222-222222222222/prescriber/details?back_url=/apply/prescriptions/list%3Fdisplay%3Dlist">Voir sa candidature</a>

</div>
</div>
Expand All @@ -403,7 +403,7 @@


chez
<a class="btn-ico btn-link" href="/company/42/card?back_url=/apply/prescriptions/list">
<a class="btn-ico btn-link" href="/company/42/card?back_url=/apply/prescriptions/list%3Fdisplay%3Dlist">
<i aria-hidden="true" class="ri-community-line fw-medium ri-sm me-1"></i>
<span>Hit pit</span>
</a>
Expand Down Expand Up @@ -462,7 +462,7 @@
</p>


<a aria-label="Gérer la candidature de J… H…" class="btn btn-outline-primary btn-block w-100 w-md-auto" data-matomo-action="clic" data-matomo-category="candidature" data-matomo-event="true" data-matomo-option="voir_candidature_prescripteur" href="/apply/33333333-3333-3333-3333-333333333333/prescriber/details?back_url=/apply/prescriptions/list">Voir sa candidature</a>
<a aria-label="Gérer la candidature de J… H…" class="btn btn-outline-primary btn-block w-100 w-md-auto" data-matomo-action="clic" data-matomo-category="candidature" data-matomo-event="true" data-matomo-option="voir_candidature_prescripteur" href="/apply/33333333-3333-3333-3333-333333333333/prescriber/details?back_url=/apply/prescriptions/list%3Fdisplay%3Dlist">Voir sa candidature</a>

</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion tests/www/apply/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_list_warns_about_long_awaiting_applications(client, snapshot):
assert str(results_section) == snapshot(name="SIAE - warnings for 2222 and 3333")

client.force_login(sender)
response = client.get(reverse("apply:list_prescriptions"))
response = client.get(reverse("apply:list_prescriptions"), {"display": JobApplicationsDisplayKind.LIST})
results_section = parse_response_to_soup(response, selector="#job-applications-section")
assert str(results_section) == snapshot(name="PRESCRIBER - warnings for 2222 and 3333")

Expand Down
27 changes: 16 additions & 11 deletions tests/www/apply/test_list_prescriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_get(client):
organization = job_application.sender_prescriber_organization
client.force_login(job_application.sender)

response = client.get(reverse("apply:list_prescriptions"))
response = client.get(reverse("apply:list_prescriptions"), {"display": JobApplicationsDisplayKind.LIST})
# Has link to export with back_url set
exports_link = unquote(
add_url_params(reverse("apply:list_prescriptions_exports"), {"back_url": reverse("apply:list_prescriptions")})
Expand Down Expand Up @@ -95,7 +95,7 @@ def test_as_unauthorized_prescriber(client, snapshot):

list_url = reverse("apply:list_prescriptions")
with assertSnapshotQueries(snapshot(name="SQL queries for prescriptions list")):
response = client.get(list_url)
response = client.get(list_url, {"display": JobApplicationsDisplayKind.LIST})

assertContains(response, "<h3>S… U…</h3>")
assertNotContains(response, "Supersecretname")
Expand Down Expand Up @@ -224,8 +224,8 @@ def test_list_display_kind(client):
LIST_VIEW_MARKER = '<div class="c-box--results__header">'

for display_param, expected_marker in [
({}, LIST_VIEW_MARKER),
({"display": "invalid"}, LIST_VIEW_MARKER),
({}, TABLE_VIEW_MARKER),
({"display": "invalid"}, TABLE_VIEW_MARKER),
({"display": JobApplicationsDisplayKind.LIST}, LIST_VIEW_MARKER),
({"display": JobApplicationsDisplayKind.TABLE}, TABLE_VIEW_MARKER),
]:
Expand All @@ -240,7 +240,7 @@ def test_list_display_kind(client):
def test_filters(client, snapshot):
client.force_login(PrescriberFactory())

response = client.get(reverse("apply:list_prescriptions"))
response = client.get(reverse("apply:list_prescriptions"), {"display": JobApplicationsDisplayKind.LIST})
assert response.status_code == 200
filter_form = parse_response_to_soup(response, "#offcanvasApplyFilters")
assert str(filter_form) == snapshot()
Expand All @@ -260,24 +260,29 @@ def test_archived(client):
</span>
"""
client.force_login(prescriber)
filter_params = {"display": JobApplicationsDisplayKind.LIST}
url = reverse("apply:list_prescriptions")
response = client.get(url)
response = client.get(url, data=filter_params)
assertContains(response, active.pk)
assertNotContains(response, archived.pk)
assertNotContains(response, archived_badge_html, html=True)
response = client.get(url, data={"archived": ""})
filter_params["archived"] = ""
response = client.get(url, data=filter_params)
assertContains(response, active.pk)
assertNotContains(response, archived.pk)
assertNotContains(response, archived_badge_html, html=True)
response = client.get(url, data={"archived": "archived"})
filter_params["archived"] = "archived"
response = client.get(url, data=filter_params)
assertNotContains(response, active.pk)
assertContains(response, archived.pk)
assertContains(response, archived_badge_html, html=True, count=1)
response = client.get(url, data={"archived": "all"})
filter_params["archived"] = "all"
response = client.get(url, data=filter_params)
assertContains(response, active.pk)
assertContains(response, archived.pk)
assertContains(response, archived_badge_html, html=True, count=1)
response = client.get(url, data={"archived": "invalid"})
filter_params["archived"] = "invalid"
response = client.get(url, data=filter_params)
assertContains(response, active.pk)
assertContains(response, archived.pk)
assertContains(response, archived_badge_html, html=True, count=1)
Expand Down Expand Up @@ -531,7 +536,7 @@ def test_reset_filter_button_snapshot(client, snapshot):
job_application = JobApplicationFactory()
client.force_login(job_application.sender)

filter_params = {"states": [job_application.state]}
filter_params = {"states": [job_application.state], "display": JobApplicationsDisplayKind.LIST}
response = client.get(reverse("apply:list_prescriptions"), filter_params)

assert str(parse_response_to_soup(response, selector="#apply-list-filter-counter")) == snapshot(
Expand Down

0 comments on commit 218a544

Please sign in to comment.