fix: export for non-owners with site permissions - #25
Merged
Conversation
…point, ensuring correct CSV export for all staff users
Contributor
Reviewer's GuideAdds a project-owned admin export endpoint for SavedFormDataEntry that reuses the existing admin export_data action with proper permissions and site scoping, rewires the inline "Export entries" button to target this endpoint, and introduces regression tests covering delegation, permissions, input validation, and site scope behavior. Sequence diagram for the new SavedFormDataEntry export endpointsequenceDiagram
actor StaffUser
participant AdminInline
participant DjangoAdminSite
participant SavedFormDataEntryAdmin
participant ExportEndpoint as Export_for_form_entry
participant ExportAction as Export_data
StaffUser->>AdminInline: Click Export_entries button
AdminInline->>AdminInline: Build action_url with reverse(admin:unfold_fobi_savedformdataentry_export)
AdminInline-->>StaffUser: Render link with form_entry_id
StaffUser->>DjangoAdminSite: GET /admin/.../export/?form_entry_id=id
DjangoAdminSite->>SavedFormDataEntryAdmin: admin_view(export_for_form_entry)
SavedFormDataEntryAdmin->>ExportEndpoint: export_for_form_entry(request)
ExportEndpoint->>SavedFormDataEntryAdmin: has_view_permission(request)
SavedFormDataEntryAdmin-->>ExportEndpoint: bool
alt No view permission
ExportEndpoint-->>StaffUser: PermissionDenied (403)
else Has view permission
ExportEndpoint->>ExportEndpoint: Read form_entry_id from request.GET
alt Missing or invalid form_entry_id
ExportEndpoint-->>StaffUser: HttpResponseBadRequest (400)
else Valid form_entry_id
ExportEndpoint->>SavedFormDataEntryAdmin: get_queryset(request)
SavedFormDataEntryAdmin-->>ExportEndpoint: Scoped queryset
ExportEndpoint->>ExportEndpoint: queryset.filter(form_entry_id=form_entry_id)
ExportEndpoint->>ExportAction: export_data(request, queryset)
ExportAction-->>StaffUser: CSV response
end
end
Class diagram for SavedFormDataEntry admin export integrationclassDiagram
class SavedFormDataEntryAdminIntegrationMixin {
+has_view_permission(request) bool
+has_change_permission(request, obj) bool
+has_delete_permission(request, obj) bool
+get_urls() list
+export_for_form_entry(request) HttpResponse
+export_data(request, queryset) HttpResponse
}
class SavedFormDataEntryAdmin {
}
class FormHandlerEntryInline {
+handler_actions(obj) list
}
class DjangoAdminSite {
+admin_view(view) view
}
SavedFormDataEntryAdminIntegrationMixin <|-- SavedFormDataEntryAdmin
FormHandlerEntryInline ..> SavedFormDataEntryAdminIntegrationMixin : uses export endpoint
SavedFormDataEntryAdminIntegrationMixin ..> DjangoAdminSite : uses admin_view
FormHandlerEntryInline ..> DjangoAdminSite : uses reverse admin_unfold_fobi_savedformdataentry_export
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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 by Sourcery
Expose a project-owned admin export endpoint for saved form data and wire the inline "Export entries" button to it, ensuring it respects site-scoped querysets and existing permissions.
Bug Fixes:
Enhancements:
Documentation:
Tests: