Skip to content

Commit

Permalink
gps: Change participants order
Browse files Browse the repository at this point in the history
  • Loading branch information
tonial committed Jan 27, 2025
1 parent ec8a25f commit 636a6f4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion itou/www/gps/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def get_context_data(self, **kwargs):
FollowUpGroupMembership.objects.with_members_organizations_names()
.filter(follow_up_group=self.object.follow_up_group)
.filter(is_active=True)
.order_by("-is_referent")
.order_by("-created_at")
.select_related("follow_up_group", "member")
)

Expand Down
17 changes: 17 additions & 0 deletions tests/gps/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import freezegun
import pytest
from django.urls import reverse
from django.utils import timezone
from pytest_django.asserts import assertContains, assertNotContains

from itou.gps.models import FollowUpGroup, FollowUpGroupMembership, FranceTravailContact
Expand Down Expand Up @@ -236,6 +237,22 @@ def test_beneficiary_details(client, snapshot):
assertContains(response, "https://formulaires.gps.inclusion.gouv.fr/ajouter-intervenant")


def test_beneficiary_details_members_order(client):
prescriber = PrescriberFactory(membership=True, membership__organization__authorized=True)
beneficiary = JobSeekerFactory(for_snapshot=True)
group = FollowUpGroupFactory(beneficiary=beneficiary, memberships=1, memberships__member=prescriber)
participant = FollowUpGroupMembershipFactory(follow_up_group=group, created_at=timezone.now()).member

client.force_login(prescriber)
user_details_url = reverse("gps:user_details", kwargs={"public_id": beneficiary.public_id})
response = client.get(user_details_url)

html_details = parse_response_to_soup(response, selector="#gps_intervenants")
cards = html_details.find_all("div", attrs={"class": "c-box c-box--results has-links-inside my-md-4"})
participant_pks = [card.attrs["id"].split("card-")[1] for card in cards]
assert participant_pks == [str(participant.public_id), str(prescriber.public_id)]


@freezegun.freeze_time("2025-01-20")
def test_display_participant_contact_info(client, mocker, snapshot):
prescriber = PrescriberFactory(
Expand Down

0 comments on commit 636a6f4

Please sign in to comment.