Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pagination to hanging protocol list page #3840

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{% block content %}
<div class="row col-12 m-0 p-0">
<h3 class="col-9 p-0">Hanging Protocols</h3>
<div class="col-3 p-0 text-right"><a class="btn btn-primary" href="{% url 'hanging-protocols:create' %}">Add a hanging protocol</a></div>
<div class="col-3 p-0 text-right"><a class="btn btn-primary" href="{% url 'hanging-protocols:create' %}"> <i class="fas fa-plus"></i> Add a new Hanging Protocol</a></div>
</div>
<br>
<div class="card-columns">
Expand Down Expand Up @@ -49,6 +49,7 @@ <h5 class="card-title">
<p>No hanging protocols available.</p>
{% endfor %}
</div>
{% include "grandchallenge/partials/pagination.html" %}
{% endblock %}

{% block script %}
Expand Down
2 changes: 1 addition & 1 deletion app/grandchallenge/hanging_protocols/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class HangingProtocolList(LoginRequiredMixin, ListView):
model = HangingProtocol
paginate_by = 50
paginate_by = 48


class HangingProtocolCreate(
Expand Down
21 changes: 21 additions & 0 deletions app/tests/hanging_protocols_tests/test_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import pytest

from grandchallenge.hanging_protocols.views import HangingProtocolList
from tests.factories import UserFactory
from tests.hanging_protocols_tests.factories import HangingProtocolFactory
from tests.utils import get_view_for_user


@pytest.mark.django_db
def test_hanging_protocol_list_view_pagination(client):
user = UserFactory()
HangingProtocolFactory.create_batch(HangingProtocolList.paginate_by + 1)

response = get_view_for_user(
client=client,
method=client.get,
viewname="hanging-protocols:list",
user=user,
)
assert response.status_code == 200
assert "Page 1 of 2" in response.rendered_content