Hide restricted and empty categories from the Doctrines filter chips - #133
Merged
Merged
Conversation
The Doctrines page filter chip bar listed every DoctrineCategory regardless of whether the viewing member was admitted to it, revealing the names and colors of restricted (opsec) categories and offering chips for categories with nothing visible in them. Add visible_categories_for(user), which restricts the chip list to categories that admit the user and currently contain at least one active, visible doctrine (managers still see everything, routed through the existing _is_manager check). The same OR-across-categories exposure existed wherever a doctrine's or fit's full category set was rendered without checking each category individually: a doctrine or fit admitted via one category could still carry a second, restricted category in its badge row. Add visible_categories_among(user, categories) and apply it to the per-doctrine category badges on the Doctrines index cards, the doctrine detail page, and the fit detail page.
The fit detail page built its doctrine chip row from the fit's full doctrine set, so a member viewing a fitting shared between a visible doctrine and a restricted one saw the restricted doctrine's name - and its chip linked to a page that is visibility-gated anyway. Build the chip list only from doctrines visible to the viewer (managers keep everything via visible_to's existing _is_manager bypass, so the Edit Doctrines UI is unaffected), and derive the combined category badge row from that same visible set. When none of a fitting's doctrines are visible, the chip row falls back to the existing "Standalone standard" empty state.
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
DoctrineCategoryunconditionally, so a member could see the name/color of a restricted (opsec) category they had no access to, or a chip for a category with nothing visible in it.visible_categories_for(user)(fitcheck/managers.py): for a manager, every category; otherwise only categories that admit the user AND currently contain at least one active, visible doctrine. Used by theindexview for the chip bar.visible_categories_among(user, categories)and apply it to:_is_managercheck (directly or viavisible_to) rather than re-implementing it, so managers - including the Edit Doctrines UI on the fit page - see everything, unchanged.Test plan
manage.py test fitcheck- 751 tests, all passingmanage.py check- no issuesmanage.py makemigrations fitcheck --check --dry-run- no changes (no migration in this PR)fitcheck/tests/test_category_visibility.pycover: admitted category with a visible doctrine (shown), restricted category (hidden), admitted-but-empty category (hidden), public category (shown), and manager bypass - at both the helper level and via a GET of the Doctrines index page; a doctrine/fit carrying one admitted and one restricted category, checked on the index cards, doctrine detail page, and fit detail page; and the fit detail doctrine chips - member sees only the visible doctrine's chip, manager sees both, and a fit whose only doctrine is restricted renders the "Standalone standard" empty state.