[fix:ux] Fixed rendering of JSON fields in readonly mode #848#1102
[fix:ux] Fixed rendering of JSON fields in readonly mode #848#1102pandafy wants to merge 3 commits into
Conversation
27f544f to
728ab65
Compare
728ab65 to
c28442a
Compare
nemesifier
left a comment
There was a problem hiding this comment.
Thanks @pandafy, this is the proper fix for #848. The ReadOnlyJsonFieldMixin approach, swapping JSON field widgets to a ReadOnlyJsonWidget (with disabled=True) for users who lack change permission, is the right way around Django's limitation that a single widget cannot serve both editable and read-only contexts. Handling both models.JSONField and jsonfield.JSONField, covering the inline path via get_formset, and including tests all make this a clean, mergeable change.
Note: there is a competing PR for the same issue (#1327) which is full of accidentally committed artifacts (a db.sqlite3, an anti_gravity.py script that disables GIS, etc.). This PR is the correct one; #1327 should be closed in its favor.
A couple of things to confirm before merge:
- Make sure this plays well with the advanced JSON editor: a view-only user should get the read-only rendering, and the change is scoped so it never downgrades the editable widget for users who do have change permission.
- Confirm coverage extends to all the JSON fields users actually see read-only (device
config,context, DeviceGroupcontext, templateconfig), so the fix is complete rather than only on one form. - Docs box is unchecked; a short note is fine since this is mostly transparent.
Good work, this is close to ready.
Checklist
Reference to Existing Issue
Fixes #848
Screenshot