Skip to content

Commit

Permalink
(PC-32561)[BO] fix: conditions for email updated icon
Browse files Browse the repository at this point in the history
NEW_EMAIL_SELECTION added in 2024 had never been taken into account in the backoffice
  • Loading branch information
prouzet-pass committed Nov 12, 2024
1 parent 8b642f4 commit a580508
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/src/pcapi/core/users/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,8 @@ def search_public_account_in_history_email(search_query: str) -> BaseQuery:
models.UserEmailHistory.oldEmail == sanitized_term,
models.UserEmailHistory.eventType.in_(
{
models.EmailHistoryEventTypeEnum.NEW_EMAIL_SELECTION,
models.EmailHistoryEventTypeEnum.CONFIRMATION,
models.EmailHistoryEventTypeEnum.VALIDATION,
models.EmailHistoryEventTypeEnum.ADMIN_VALIDATION,
models.EmailHistoryEventTypeEnum.ADMIN_UPDATE,
Expand Down
1 change: 1 addition & 0 deletions api/src/pcapi/routes/backoffice/accounts/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ def render_public_account_details(
email_event.eventType
not in (
users_models.EmailHistoryEventTypeEnum.UPDATE_REQUEST,
users_models.EmailHistoryEventTypeEnum.NEW_EMAIL_SELECTION,
users_models.EmailHistoryEventTypeEnum.CANCELLATION,
)
for email_event in user.email_history
Expand Down
2 changes: 2 additions & 0 deletions api/src/pcapi/routes/backoffice/accounts/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ def actionType(self) -> history_models.ActionType | str:
match self._email_change.eventType:
case users_models.EmailHistoryEventTypeEnum.UPDATE_REQUEST:
return "Demande de changement d'email"
case users_models.EmailHistoryEventTypeEnum.NEW_EMAIL_SELECTION:
return "Saisie d'une nouvelle adresse email"
case users_models.EmailHistoryEventTypeEnum.CONFIRMATION:
return "Confirmation de changement d'email"
case users_models.EmailHistoryEventTypeEnum.CANCELLATION:
Expand Down
2 changes: 2 additions & 0 deletions api/tests/routes/backoffice/accounts_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ def test_get_suspended_public_account(self, legit_user, authenticated_client):
def test_get_public_account_with_unconfirmed_modified_email(self, authenticated_client):
user = users_factories.UserFactory()
users_factories.EmailUpdateEntryFactory(user=user)
users_factories.NewEmailSelectionEntryFactory(user=user)
user_id = user.id

with assert_num_queries(self.expected_num_queries):
Expand All @@ -702,6 +703,7 @@ def test_get_public_account_with_unconfirmed_modified_email(self, authenticated_
def test_get_public_account_with_confirmed_modified_email(self, authenticated_client):
user = users_factories.UserFactory()
users_factories.EmailUpdateEntryFactory(user=user)
users_factories.NewEmailSelectionEntryFactory(user=user)
users_factories.EmailConfirmationEntryFactory(user=user)
user_id = user.id

Expand Down

0 comments on commit a580508

Please sign in to comment.