fix: NoReverseMatch: Reverse for 'filer_file_expand' not found error for svgs - #1619
Conversation
Reviewer's GuideCentralizes SVG expansion in the base file admin so SVGs stored as generic File records use the correct model-specific admin URL, are protected by read permissions, and are covered by change-form, view, authorization, and directory-listing tests. Sequence diagram for SVG expansion in the file adminsequenceDiagram
participant AdminBrowser
participant FileAdmin
participant DjangoURLResolver
participant File
participant Permissions
participant TemplateResponse
AdminBrowser->>FileAdmin: render_change_form(request, context)
FileAdmin->>DjangoURLResolver: reverse(admin_urlname(self.opts, expand), file_id)
DjangoURLResolver-->>FileAdmin: model-specific expand URL
FileAdmin-->>AdminBrowser: change form with expand_image_url
AdminBrowser->>FileAdmin: expand_view(request, file_id)
FileAdmin->>File: get_object_or_404(self.model, pk=file_id)
File-->>FileAdmin: file
FileAdmin->>Permissions: has_admin_read_permission(request, file)
alt read permission granted
FileAdmin->>TemplateResponse: TemplateResponse(request, expand.html, original_url)
TemplateResponse-->>AdminBrowser: expanded SVG
else read permission denied
FileAdmin-->>AdminBrowser: Http404
end
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1619 +/- ##
==========================================
- Coverage 83.18% 83.17% -0.01%
==========================================
Files 79 79
Lines 4003 4001 -2
Branches 549 550 +1
==========================================
- Hits 3330 3328 -2
Misses 520 520
Partials 153 153 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Documentation build overview
40 files changed ·
|
|
@sourcery-ai review |
|
@sourcery-ai review |
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. The new expand endpoint serves the file's original URL after an admin read-permission check, so an incorrect permission check could disclose files to an unauthorized user. Reverting would remove the endpoint but would not undo any exposure that already occurred.
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Summary by Sourcery
Support expanding SVG files regardless of whether they are stored as Image or File records.
New Features:
Bug Fixes:
Enhancements:
Tests:
Related resources
filer_file_expandwhen listing SVG files in folder view #1590Checklist
masterDiscord to find a “pr review buddy” who is going to review my pull request.