Skip to content

Commit

Permalink
Clarify delete_user_data and get_user functions of gdpr api
Browse files Browse the repository at this point in the history
  • Loading branch information
henrinie-nc committed Nov 19, 2024
1 parent 8e63439 commit 4d1a10f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion gdpr/utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from helsinki_gdpr.views import DryRunException

from users.models import User


def get_user(user: User) -> User:
"""
Get the user provider, as User is the GDPR API root model. GDPR API implementation
by default attempts to get it from the root models user attribute.
This function is used by defining it as the value for setting `GDPR_API_USER_PROVIDER`.
"""
return user

Expand All @@ -13,4 +16,7 @@ def delete_user_data(user: User, dry_run: bool) -> None:
"""
Delete user data.
"""
user.delete()
if dry_run:
raise DryRunException("Dry run. Rollback delete transaction.")
else:
user.delete()
2 changes: 1 addition & 1 deletion mvj/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def get_git_revision_hash():
GDPR_API_MODEL_LOOKUP=(str, "uuid"),
GDPR_API_QUERY_SCOPE=(str, ""),
GDPR_API_DELETE_SCOPE=(str, ""),
GDPR_API_USER_PROVIDER=(str, ""),
GDPR_API_USER_PROVIDER=(str, "gdpr.utils.get_user"),
GDPR_API_DELETER=(str, "gdpr.utils.delete_user_data"),
)

Expand Down

0 comments on commit 4d1a10f

Please sign in to comment.