Skip to content

Commit

Permalink
gps: Display membership date
Browse files Browse the repository at this point in the history
Now that we have the correct date
  • Loading branch information
tonial committed Jul 15, 2024
1 parent 84a043e commit 6921428
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 45 deletions.
16 changes: 5 additions & 11 deletions itou/templates/gps/includes/memberships_results.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,11 @@ <h3>{{ membership.follow_up_group.beneficiary.get_full_name }}</h3>
<div>
{% with membership.nb_members|add:"-1" as counter %}
<div>
{% if not membership.created_in_bulk %}
<div>
{# djlint:off #}
{# Don't let djlint add a newline before the . or it will add a space after référent and . #}
Vous avez ajouté ce bénéficiaire le <strong>{{ membership.created_at|date:"d/m/Y" }}</strong>{% if membership.is_referent %} et êtes <strong>référent</strong>{% endif %}.{# djlint:on #}
</div>
{% elif membership.is_referent %}
<div>
Vous êtes <strong>référent</strong>.
</div>
{% endif %}
<div>
{# djlint:off #}
{# Don't let djlint add a newline before the . or it will add a space after référent and . #}
Vous avez ajouté ce bénéficiaire le <strong>{{ membership.created_at|date:"d/m/Y" }}</strong>{% if membership.is_referent %} et êtes <strong>référent</strong>{% endif %}.{# djlint:on #}
</div>
{% if counter < 1 %}
Aucun autre professionnel que vous n'est intervenu auprès de ce bénéficiaire.
{% else %}
Expand Down
12 changes: 5 additions & 7 deletions tests/gps/__snapshots__/test_views.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,11 @@
<div>

<div>

<div>


Vous avez ajouté ce bénéficiaire le <strong>21/06/2024</strong>.
</div>

<div>


Vous avez ajouté ce bénéficiaire le <strong>21/06/2024</strong>.
</div>

1 autre professionnel
est
Expand Down
29 changes: 2 additions & 27 deletions tests/gps/test_views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import datetime

import freezegun
import pytest
from django.conf import settings
from django.test.utils import override_settings
from django.urls import reverse
from pytest_django.asserts import assertContains, assertRedirects
Expand Down Expand Up @@ -195,28 +192,6 @@ def test_my_groups(snapshot, client):
user = PrescriberFactory(membership__organization__authorized=True, membership__organization__for_snapshot=True)
client.force_login(user)

# Was created in bulk.
group = FollowUpGroupFactory(
memberships=1,
beneficiary__first_name="Paco",
beneficiary__last_name="de Lucia",
created_in_bulk=True,
)

FollowUpGroup.objects.follow_beneficiary(beneficiary=group.beneficiary, user=user, is_referent=True)
membership = group.memberships.get(member=user)
membership.created_at = datetime.datetime.combine(
settings.GPS_GROUPS_CREATED_AT_DATE, datetime.time(), tzinfo=datetime.UTC
)
membership.created_in_bulk = True
membership.save()

response = client.get(reverse("gps:my_groups"))
assert response.status_code == 200
groups = parse_response_to_soup(response, selector="#follow-up-groups-section").select(".membership-card")
assert len(groups) == 1
assert "Vous avez ajouté ce bénéficiaire le" not in str(groups[0])

# Nominal case
# Groups created latelly should come first.
group = FollowUpGroupFactory(memberships=1, for_snapshot=True)
Expand All @@ -230,15 +205,15 @@ def test_my_groups(snapshot, client):
("data-bs-confirm-url", f"/gps/groups/{group.pk}", "/gps/groups/[PK of Group]"),
],
).select(".membership-card")
assert len(groups) == 2
assert len(groups) == 1
assert str(groups[0]) == snapshot(name="test_my_groups__group_card")

# Test `is_referent` display.
group = FollowUpGroupFactory(memberships=1, beneficiary__first_name="Janis", beneficiary__last_name="Joplin")
FollowUpGroup.objects.follow_beneficiary(beneficiary=group.beneficiary, user=user, is_referent=True)
response = client.get(reverse("gps:my_groups"))
groups = parse_response_to_soup(response, selector="#follow-up-groups-section").select(".membership-card")
assert len(groups) == 3
assert len(groups) == 2
assert "Janis" in str(groups[0])
assert "et êtes <strong>référent</strong>" in str(groups[0])

Expand Down

0 comments on commit 6921428

Please sign in to comment.