Repository navigation
Replace an old FIXME comment with an explanation why a fix is not nee… - #1554
Merged
Merged
Conversation
sayravai
force-pushed
the
REPLACE_OLD_FIXME
branch
from
October 7, 2026 06:25
e56bea6 to
00a3120
Compare
ihalaij1
force-pushed
the
REPLACE_OLD_FIXME
branch
from
October 9, 2026 07:56
00a3120 to
f3d0105
Compare
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.
…ded. Fix another FIXME in the same file by using Django time formatting.
Description
This PR only replaces an old FIXME comment by an explanation. It also fixes another FIXME in the same file by using Django datetime formatting to match user settings instead of a default datetime string.
What the old FIXME is about
CourseVisiblePermissionBase.is_object_visible() (course/permissions.py) decides whether a CourseInstance is visible by looking at the view_content_to field of the course instance (PUBLIC / ENROLLMENT_AUDIENCE / ENROLLED). The FIXME says the check should probably also consider the view's get_access_mode(): if the view declares itself ACCESS.ANONYMOUS (i.e., "anyone may access this view"), the course should arguably be treated as visible even if view_content_to != PUBLIC.
Why it was never done — the reason is still accurate today:
For normal UI views it's redundant. AccessModePermission runs before this permission (lib/viewbase.py adds it first), and CourseInstanceBaseMixin.get_access_mode() (course/viewbase.py:152) already loosens STUDENT/ENROLL views to ANONYMOUS exactly when the instance is public — using the same view_content_to field this permission checks. So an "ANONYMOUS access mode" would imply PUBLIC anyway, and the check adds nothing.
For API views it would break things, like the original FIXME's warns. API resources never really use access modes: course/api/mixins.py:17 and exercise/api/mixins.py:40,66 hard-code access_mode = ACCESS.ANONYMOUS with the comment "not really used" (it exists only so super().get_access_mode() doesn't crash). exercise/api/views.py:449 even does the opposite hack — returning ACCESS.STUDENT/ENROLL regardless of the course's visibility, "so that enrollment exercises work in the CourseVisiblePermission". If is_object_visible() consulted view.get_access_mode(), every API course — public or not — would look "anonymous/public" to non-enrolled users, bypassing the view_content_to and enrollment-audience checks.
So the "hole" is theoretical: no UI view today declares ANONYMOUS while the instance is non-public (everything public gets it via the loosening logic, e.g. course/views.py:42,102,124,145 plus the rule in viewbase.py), and the API deliberately hard-codes it to ANONYMOUS, which is exactly the case we must not trust.
Why?
[ANSWER HERE]
How?
[ANSWER HERE]
Fixes #
Testing
Remember to add or update unit tests for new features and changes.
What type of test did you run?
[ADD A DESCRIPTION ABOUT WHAT YOU TESTED MANUALLY]
Did you test the changes in
Think of what is affected by these changes and could become broken
Translation
Programming style
Have you updated the README or other relevant documentation?
Is it Done?
Clean up your git commit history before submitting the pull request!