* 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
107 lines
5.7 KiB
Text
107 lines
5.7 KiB
Text
<%= form_for @users_notification_setting, url: users_notification_settings_path do |f| %>
|
|
<div class="crayons-card crayons-card--content-rows">
|
|
<header>
|
|
<h2 class="crayons-subtitle-1">
|
|
<%= t("views.settings.notifications.email") %>
|
|
</h2>
|
|
</header>
|
|
<div class="crayons-field crayons-field--checkbox">
|
|
<%= f.check_box :email_newsletter, class: "crayons-checkbox" %>
|
|
<%= f.label :email_newsletter, "Send me weekly newsletter emails", class: "crayons-field__label" %>
|
|
</div>
|
|
<div class="crayons-field crayons-field--checkbox">
|
|
<%= f.check_box :email_digest_periodic, class: "crayons-checkbox" %>
|
|
<%= f.label :email_digest_periodic, "Send me a periodic digest of top posts from my tags", class: "crayons-field__label" %>
|
|
</div>
|
|
<% if current_user.a_sustaining_member? %>
|
|
<div class="crayons-field crayons-field--checkbox">
|
|
<%= f.check_box :email_membership_newsletter, class: "crayons-checkbox" %>
|
|
<%= f.label :email_membership_newsletter, "Send me sustaining membership newsletter emails", class: "crayons-field__label" %>
|
|
</div>
|
|
<% end %>
|
|
<% if current_user.tag_moderator? %>
|
|
<div class="crayons-field crayons-field--checkbox">
|
|
<%= f.check_box :email_tag_mod_newsletter, class: "crayons-checkbox" %>
|
|
<%= f.label :email_tag_mod_newsletter, "Send me tag moderator newsletter emails", class: "crayons-field__label" %>
|
|
</div>
|
|
<% end %>
|
|
<% if current_user.has_trusted_role? %>
|
|
<div class="crayons-field crayons-field--checkbox">
|
|
<%= f.check_box :email_community_mod_newsletter, class: "crayons-checkbox" %>
|
|
<%= f.label :email_community_mod_newsletter, "Send me community moderator newsletter emails", class: "crayons-field__label" %>
|
|
</div>
|
|
<% end %>
|
|
<div class="crayons-field crayons-field--checkbox">
|
|
<%= f.check_box :email_comment_notifications, class: "crayons-checkbox" %>
|
|
<%= f.label :email_comment_notifications, "Send me an email when someone replies to me in a comment thread", class: "crayons-field__label" %>
|
|
</div>
|
|
<div class="crayons-field crayons-field--checkbox">
|
|
<%= f.check_box :email_follower_notifications, class: "crayons-checkbox" %>
|
|
<%= f.label :email_follower_notifications, "Send me an email when someone new follows me", class: "crayons-field__label" %>
|
|
</div>
|
|
<div class="crayons-field crayons-field--checkbox">
|
|
<%= f.check_box :email_mention_notifications, class: "crayons-checkbox" %>
|
|
<%= f.label :email_mention_notifications, "Send me an email when someone mentions me", class: "crayons-field__label" %>
|
|
</div>
|
|
<div class="crayons-field crayons-field--checkbox">
|
|
<%= f.check_box :email_badge_notifications, class: "crayons-checkbox" %>
|
|
<%= f.label :email_badge_notifications, "Send me an email when I receive a badge", class: "crayons-field__label" %>
|
|
</div>
|
|
<div class="crayons-field crayons-field--checkbox">
|
|
<%= f.check_box :email_unread_notifications, class: "crayons-checkbox" %>
|
|
<%= f.label :email_unread_notifications, t("helpers.label.users_notification_setting.email_unread_notifications", community: community_name), class: "crayons-field__label" %>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="crayons-card crayons-card--content-rows">
|
|
<header>
|
|
<h2 class="crayons-subtitle-1 flex items-center">
|
|
<%= t("views.settings.notifications.mobile") %>
|
|
</h2>
|
|
</header>
|
|
<div class="crayons-field crayons-field--checkbox">
|
|
<%= f.check_box :mobile_comment_notifications, class: "crayons-checkbox" %>
|
|
<%= f.label :mobile_comment_notifications, t("helpers.label.users_notification_setting.mobile_comment_notifications"), class: "crayons-field__label" %>
|
|
</div>
|
|
<div class="crayons-field crayons-field--checkbox">
|
|
<%= f.check_box :mobile_mention_notifications, class: "crayons-checkbox" %>
|
|
<%= f.label :mobile_mention_notifications, t("helpers.label.users_notification_setting.mobile_mention_notifications"), class: "crayons-field__label" %>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="crayons-card crayons-card--content-rows">
|
|
<header>
|
|
<h2 class="crayons-subtitle-1">
|
|
<%= t("views.settings.notifications.general") %>
|
|
</h2>
|
|
<p class="color-base-70">
|
|
<%= t("views.settings.notifications.general_desc_html", page: link_to(t("views.settings.notifications.page"), notifications_path)) %>
|
|
</p>
|
|
</header>
|
|
<div class="crayons-field crayons-field--checkbox">
|
|
<%= f.check_box :welcome_notifications, class: "crayons-checkbox" %>
|
|
<%= f.label :welcome_notifications, t("helpers.label.users_notification_setting.welcome_notifications", community: community_name), class: "crayons-field__label" %>
|
|
</div>
|
|
<div class="crayons-field crayons-field--checkbox">
|
|
<%= f.check_box :reaction_notifications, class: "crayons-checkbox" %>
|
|
<%= f.label :reaction_notifications, "Send notifications when someone reacts to my comments or posts", class: "crayons-field__label" %>
|
|
</div>
|
|
</div>
|
|
|
|
<% if current_user.trusted? %>
|
|
<div class="crayons-card crayons-card--content-rows">
|
|
<h2 class="crayons-subtitle-1">
|
|
<%= t("views.settings.notifications.moderator") %>
|
|
</h2>
|
|
<div class="crayons-field crayons-field--checkbox">
|
|
<%= f.check_box :mod_roundrobin_notifications, class: "crayons-checkbox" %>
|
|
<%= f.label :mod_roundrobin_notifications, "Send me occasional community-success mod notifications", class: "crayons-field__label" %>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
|
|
<div class="crayons-card crayons-card--content-rows">
|
|
<button type="submit" class="crayons-btn"><%= t("views.settings.notifications.save") %></button>
|
|
</div>
|
|
|
|
<% end %>
|