docbrown/app/views/admin
Jeremy Friesen a40efc6bbd
Refactoring questions asked of user (#15762)
* Refactoring questions asked of user

In this pull request, I'm extracting and normalizing role-based
questions asked of the user.

Prior to this commit, our codebase has asked two very similar questions
of our user model:

- `user.has_role?(:admin)`
- `user.admin?`

In asking `has_role?(:admin)` we are relying on implementation details
of the rolify gem.  In addition, the `has_role?` question asked
throughout controllers or views means that it's harder to create
hieararchies of permissions.

In favoring `user.admin?` as our question, we can use that indirection
as an opportunity to discuss and decide "Should someone with the
`:super_admin` role be `user.admin? == true`?"

The details of this commit is to do three primary things:

1. Ask the `has_role?` questions in "one place" in the code (e.g. the
   `Authorizer` module)
2. Extract the role based questions that are on the `User` model and
   provde backwards compatable delegation.
3. Structure the code so that it's harder to accidentally call
   `user.has_role?` (e.g., make `User#has_role?` and `User#has_any_role?`
   private).

This is related to #15624 and the updates are informed by discussion in
PR #15691.  This commit supplants #15691.

* Refactoring the liquid tag policy tests

* Fixing typo

* Bump for travis
2021-12-21 12:45:12 -05:00
..
articles role deprecation cleanup (#15717) 2021-12-09 15:27:45 -06:00
badge_achievements Heavy Confirmation Flow for Broadcast-Destroy (#14819) 2021-09-29 07:43:00 -04:00
badges Add loading=lazy to image tags (#10888) 2021-05-27 19:01:21 +02:00
broadcasts Heavy Confirmation Flow for Broadcast-Destroy (#14819) 2021-09-29 07:43:00 -04:00
comments Add loading=lazy to image tags (#10888) 2021-05-27 19:01:21 +02:00
consumer_apps Make Consumer Apps dictate aasa results (#14015) 2021-06-24 08:36:11 -06:00
creator_settings Changed members only copy for radio button label to invite only. (#15795) 2021-12-16 08:31:31 -05:00
data_update_scripts Admin DataUpdateScripts: fix Re-run button label (#13825) 2021-05-21 17:35:09 +02:00
display_ads Upgrade Stimulus to 3.0 (#14869) 2021-10-05 20:00:37 +02:00
email_messages Look for <html> tags instead of <body> for other emails (#14547) 2021-08-19 16:53:45 -04:00
feedback_messages Spelling fixes to live code (#15670) 2021-12-06 12:11:25 +02:00
html_variants Spelling fixes to live code (#15670) 2021-12-06 12:11:25 +02:00
invitations Only enable user invitations page when SMTP is enabled (#15219) 2021-10-29 17:41:30 +02:00
listing_categories RFC#50-P5 Prepares the admin restructure to be tested (#13114) 2021-04-15 14:53:46 +02:00
listings [15-min-fix] Add org id to admin listings form (#14162) 2021-07-08 09:23:10 -04:00
moderator_actions Override specified line break behaviour on the ID column (#12076) 2021-01-04 16:17:38 -05:00
mods Override specified line break behaviour on the ID column (#12076) 2021-01-04 16:17:38 -05:00
navigation_links Escape the backslash in the string (#15232) 2021-11-01 08:59:20 -05:00
organizations Spelling fixes to live code (#15670) 2021-12-06 12:11:25 +02:00
overview [15-min fix] Small tweaks for small screen usage in Admin (#14341) 2021-08-04 12:21:57 -06:00
pages Refactoring questions asked of user (#15762) 2021-12-21 12:45:12 -05:00
permissions Override specified line break behaviour on the ID column (#12076) 2021-01-04 16:17:38 -05:00
podcasts Fix and clean up podcast pages (#15004) 2021-10-15 17:38:57 -04:00
privileged_reactions Don't show reactions to missing reactables (#15249) 2021-12-09 14:40:17 -06:00
profile_fields Escape periods and display the group name properly (#15819) 2021-12-17 17:35:42 -05:00
response_templates RFC#50-P5 Prepares the admin restructure to be tested (#13114) 2021-04-15 14:53:46 +02:00
secrets RFC#50-P5 Prepares the admin restructure to be tested (#13114) 2021-04-15 14:53:46 +02:00
settings Refactoring questions asked of user (#15762) 2021-12-21 12:45:12 -05:00
shared Added the logo upload to the admin -> customization -> config -> images section. (#15729) 2021-12-15 14:10:27 -05:00
sponsorships RFC#50-P5 Prepares the admin restructure to be tested (#13114) 2021-04-15 14:53:46 +02:00
tags Update tag's style (#15266) 2021-11-11 14:03:31 -05:00
tools [deploy] Add a simple image uploader partial (#10884) 2020-10-21 16:41:50 +02:00
users Refactoring questions asked of user (#15762) 2021-12-21 12:45:12 -05:00
webhook_endpoints [deploy] Adding Crayons to Admin (#10015) 2020-08-31 10:29:06 -04:00
welcome Titles & subtitles cleanup (#10508) 2020-10-02 12:37:39 +02:00