Skip to content

Commit

Permalink
(PC-31164)[API] feat: remove pending anonymisation when reactivating …
Browse files Browse the repository at this point in the history
…user account
  • Loading branch information
Meewan committed Aug 27, 2024
1 parent e1e569d commit 6e2ac7d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/src/pcapi/core/users/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ def unsuspend_account(
suspension_reason = user.suspension_reason
user.isActive = True
db.session.add(user)
users_models.GdprUserAnonymization.query.filter(users_models.GdprUserAnonymization.userId == user.id).delete()

history_api.add_action(history_models.ActionType.USER_UNSUSPENDED, author=actor, user=user, comment=comment)

Expand Down
13 changes: 13 additions & 0 deletions api/tests/routes/backoffice/users_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,19 @@ def test_unsuspend_beneficiary_user(self, authenticated_client, legit_user):
assert user.action_history[0].venueId is None
assert user.action_history[0].comment is None

def test_unsuspend_beneficiary_to_anonymize(self, authenticated_client, legit_user):
user = users_factories.BeneficiaryGrant18Factory(isActive=False)
users_factories.GdprUserAnonymizationFactory(user=user)

response = self.post_to_endpoint(
authenticated_client, user_id=user.id, form={"comment": ""}, follow_redirects=True
)

assert response.status_code == 200
assert user.isActive
assert len(user.action_history) == 1
assert users_models.GdprUserAnonymization.query.count() == 0

def test_unsuspend_pro_user(self, authenticated_client, legit_user):
user = users_factories.ProFactory(isActive=False)
offerers_factories.UserOffererFactory(user=user)
Expand Down

0 comments on commit 6e2ac7d

Please sign in to comment.