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.
Implements SYS-1612 and SYS-1621, with other minor changes. Tagged as version
v1.1.7
for deployment.This PR primarily fixes two bugs:
serve
view used withmedia/
paths is now wrapped by a customserve_media_files
view, which requires login. Otherwise, anyone who could figure out a URL for a master file could download it from anywhere. There also are tests covering this now.delete_file
view. The check for group membership has been added to the view itself, and aPermissionDenied
exception is raised with HTTP 403 (and message logged) if violated. This protects against the unlikely, but possible, case where a valid but unauthorized user could figure out the URL to delete a file via the view, and called that URL directly.Other minor changes:
upload_file
to include file name as tertiary sort, after sequence and file code. This fixes a (visual) problem where submasters for PDF/XML files could be listed before masters, since there's no special submaster file codes for those.Testing
(Re)start system to pick up changes from
requirements.txt
.There are 107 tests, all should pass.
For extra manual testing / confirmation
MediaFile.id
, then go to http://127.0.0.1:8000/delete_file/that_id .PermissionDenied
exception, along with something likeWARNING 2024-05-24 12:16:16,204 oh_staff_ui.views views Unauthorized attempt to delete oh_static/pdf/submasters/fake-ce54fea54d-2-submaster.pdf (25475) by akohler
Location
redirect to the login screen