hmpf / easydmp

MIT License
7 stars 2 forks source link

Switch from is_superuser to ha(s|ve)_superpowers #186

Closed hmpf closed 3 years ago

hmpf commented 3 years ago

User.has_superpowers and User.objects.have_superpowers() check that the user is both active and staff in addition to being superuser.

codecov[bot] commented 3 years ago

Codecov Report

Merging #186 (7acbfb0) into master (9451f43) will increase coverage by 0.03%. The diff coverage is 40.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #186      +/-   ##
==========================================
+ Coverage   55.75%   55.79%   +0.03%     
==========================================
  Files         112      112              
  Lines        6191     6200       +9     
==========================================
+ Hits         3452     3459       +7     
- Misses       2739     2741       +2     
Impacted Files Coverage Δ
src/easydmp/auth/api/v1/views.py 44.70% <0.00%> (ø)
src/easydmp/auth/api/v2/views.py 44.70% <0.00%> (ø)
src/easydmp/dmpt/admin.py 54.96% <0.00%> (ø)
src/easydmp/dmpt/models.py 52.10% <0.00%> (ø)
src/easydmp/lib/admin.py 40.42% <0.00%> (ø)
src/easydmp/auth/models.py 83.33% <72.72%> (-3.34%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9451f43...7acbfb0. Read the comment docs.

hmpf commented 3 years ago

This ensures that we can prevent superusers from doing things by simply toggling is_active and not deleting the user. Strictly speaking, checking for is_staff is not necessary, but currently there's no point in being superuser without also being staff.