Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions templates/volunteer/_schedule_filters.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ <h3>Filters</h3>
/>
Show shifts in the past
</label>
{% if not is_admin %}
<label class="checkbox">
<input
type="checkbox"
id="show_signed_up_only"
/>
Show my shifts
</label>
{% endif %}
<label class="checkbox">
<input
type="checkbox"
Expand Down
31 changes: 31 additions & 0 deletions tests/volunteer/test_schedule_filters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""Tests for volunteer schedule filter visibility."""


def test_show_my_shifts_filter_hidden_for_admin():
"""Volunteer admins should not see the 'Show my shifts' filter."""
from main import create_app

app = create_app()
with app.test_request_context("/"):
from flask import render_template_string

result = render_template_string(
"{% from 'volunteer/_schedule_filters.html' import vol_schedule_filters %}"
"{{ vol_schedule_filters([], is_admin=True) }}"
)
assert "show_signed_up_only" not in result


def test_show_my_shifts_filter_visible_for_non_admin():
"""Regular volunteers should see the 'Show my shifts' filter."""
from main import create_app

app = create_app()
with app.test_request_context("/"):
from flask import render_template_string

result = render_template_string(
"{% from 'volunteer/_schedule_filters.html' import vol_schedule_filters %}"
"{{ vol_schedule_filters([], is_admin=False) }}"
)
assert "show_signed_up_only" in result