feat: add subject access request (SAR) data export for staff console#663
Open
Joe-Heffer-Shef wants to merge 2 commits into
Open
feat: add subject access request (SAR) data export for staff console#663Joe-Heffer-Shef wants to merge 2 commits into
Joe-Heffer-Shef wants to merge 2 commits into
Conversation
Wires up the reserved DataProtectionEvent.EventType.EXPORT flow (UK GDPR Art. 15). Staff can generate a JSON export of a user's own profile, organisation memberships, projects created, and data protection history from a new console view, without including other users' personal data. Closes #582. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This comment was marked as resolved.
This comment was marked as resolved.
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements #582 — a staff console action that generates a UK GDPR Article 15 subject access export for a given user, as JSON.
Screenshots
Changes
This wires up
DataProtectionEvent.EventType.EXPORT, which was already defined in the data protection audit log but documented as "reserved" (docs/data-protection.md) pending this exact flow.UserService.export_personal_data(user)builds a dict of the user's own data: profile fields, organisation memberships (their own only), and projects they created — reusing the same queries as the existingConsoleUserDetailView.ConsoleExportUserDataView(staff-only) follows the existing GET-confirm / POST-act console pattern used byConsoleDeleteUserView. POST returns the export as a downloadable JSON attachment and merges in the user'sdata_protection_history(their own audit events, with staff identities stripped), then records a newexportaudit event viadata_protection_service.record_event.Scope note
The issue's suggested scope mentions survey responses and invitations, but in this schema neither
SurveyResponsenorInvitationhas a foreign key toUser— responses are anonymous (collected via invitation token) and invitations only carry a raw email address. So there's no account-linked survey/invitation data to include; the real personal-data surface for aUseraccount is profile fields, their own organisation memberships, projects they created, and their own data protection history. This export deliberately excludes other organisation members' data even where membership records are shared.Test plan
python manage.py test home/tests/test_console_views.py --failfast— new tests cover: GET confirmation, POST JSON download + content, exclusion of other members' personal data, audit event recording, 403 for erased accounts, staff-only access, anonymous redirect.python manage.py test home/tests --parallel=auto --failfast— fullhomesuite passes (114 tests).python manage.py check/makemigrations --check --dry-run— no issues, no missing migrations./console/users/<pk>/, confirmed the "Export data (SAR)" button and confirmation page render, POSTed to download the JSON export with correctContent-Disposition/Content-Typeand expected data, and confirmed the newexportevent appears in/console/data-protection/.🤖 Generated with Claude Code