feat: grant staff access to superusers automatically (#38848)
* feat: grant staff access to superusers automatically Django's is_superuser and is_staff are independent flags, so a superuser does not get the is_staff access that gates the Django admin and various staff-only Studio/LMS views. Since a superuser can grant itself is_staff at any time, that split offers no protection and is only surprising. Add a pre_save signal on the User model that marks any superuser as staff, and a data migration to backfill existing superusers. Discussion: https://discuss.openedx.org/t/shouldnt-superuser-automatically-inherit-staff-access-in-open-edx/18657 * refactor: address review feedback on superuser staff grant - Reword the receiver, migration, and test docstrings to describe the behaviour as grant-only rather than keeping is_staff "in sync" with is_superuser, since demoting a superuser never revokes is_staff. - Exercise the pre_save receiver with an explicit save() in the non-superuser test instead of relying only on factory creation. - Add test_demotion_does_not_remove_staff to lock in the one-directional contract.
A
Abdul-Muqadim-Arbisoft committed
e15695df03cb9c4701061e25e86fdf3b33582354
Parent: 02467e5
Committed by GitHub <noreply@github.com>
on 7/29/2026, 8:16:53 AM