diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 2636d5a88..66543e15c 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -41,7 +41,8 @@ end module StreamRails class Enrich def retrieve_objects(references) - Hash[references.map { |model, ids| [model, Hash[construct_query(model, ids).map { |i| [i.id.to_s, i] }]] }] + Hash[references. + map { |model, ids| [model, Hash[construct_query(model, ids).map { |i| [i.id.to_s, i] }]] }] end def construct_query(model, ids) diff --git a/app/models/user.rb b/app/models/user.rb index eb6e22df6..b409a5984 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -94,8 +94,10 @@ class User < ApplicationRecord :employment_title, :education, :location, length: { maximum: 100 } validates :mostly_work_with, :currently_learning, :currently_hacking_on, - :available_for, :mentee_description, :mentor_description, + :available_for, length: { maximum: 500 } + validates :mentee_description, :mentor_description, + length: { maximum: 1000 } validate :conditionally_validate_summary validate :validate_feed_url validate :unique_including_orgs @@ -202,6 +204,7 @@ class User < ApplicationRecord "user-#{id}-#{updated_at}-#{following_users_count}/following_users_ids", expires_in: 120.hours, ) do + # More efficient query. May not cover future edge cases. # Should probably only return users who have published lately # But this should be okay for most for now. diff --git a/app/policies/admin_policy.rb b/app/policies/admin_policy.rb index 621181143..54edb7950 100644 --- a/app/policies/admin_policy.rb +++ b/app/policies/admin_policy.rb @@ -1,5 +1,5 @@ class AdminPolicy < ApplicationPolicy def show? - user_is_admin? + user_admin? end end diff --git a/app/policies/application_policy.rb b/app/policies/application_policy.rb index 0a6245c2d..d86158494 100644 --- a/app/policies/application_policy.rb +++ b/app/policies/application_policy.rb @@ -53,7 +53,7 @@ class ApplicationPolicy end end - def user_is_admin? + def user_admin? user.has_role?(:super_admin) end diff --git a/app/policies/article_policy.rb b/app/policies/article_policy.rb index 9c15c6029..c7d88d156 100644 --- a/app/policies/article_policy.rb +++ b/app/policies/article_policy.rb @@ -1,6 +1,6 @@ class ArticlePolicy < ApplicationPolicy def update? - user_is_author? || user_is_admin? || user_is_org_admin? + user_is_author? || user_admin? || user_org_admin? end def new? @@ -24,7 +24,7 @@ class ArticlePolicy < ApplicationPolicy end def analytics_index? - (user_is_author? && user_can_view_analytics?) || user_is_org_admin? + (user_is_author? && user_can_view_analytics?) || user_org_admin? end def permitted_attributes @@ -39,7 +39,7 @@ class ArticlePolicy < ApplicationPolicy record.user_id == user.id end - def user_is_org_admin? + def user_org_admin? user.org_admin && user.organization_id == record.organization_id end diff --git a/app/policies/block_policy.rb b/app/policies/block_policy.rb index 1d0e6642a..d54196d5b 100644 --- a/app/policies/block_policy.rb +++ b/app/policies/block_policy.rb @@ -1,30 +1,30 @@ class BlockPolicy < ApplicationPolicy def index? - user_is_admin? + user_admin? end def show? - user_is_admin? + user_admin? end def new? - user_is_admin? + user_admin? end def edit? - user_is_admin? + user_admin? end def create? - user_is_admin? + user_admin? end def update? - user_is_admin? + user_admin? end def destroy? - user_is_admin? + user_admin? end def permitted_attributes diff --git a/app/policies/chat_channel_policy.rb b/app/policies/chat_channel_policy.rb index b05284f07..8d378c063 100644 --- a/app/policies/chat_channel_policy.rb +++ b/app/policies/chat_channel_policy.rb @@ -12,7 +12,7 @@ class ChatChannelPolicy < ApplicationPolicy end def moderate? - !user_is_banned? && user_is_admin? + !user_is_banned? && user_admin? end def show? diff --git a/app/policies/tag_policy.rb b/app/policies/tag_policy.rb index c95f6fd1e..322507f80 100644 --- a/app/policies/tag_policy.rb +++ b/app/policies/tag_policy.rb @@ -14,7 +14,7 @@ class TagPolicy < ApplicationPolicy private def has_mod_permission? - user_is_admin? || + user_admin? || user.has_role?(:tag_moderator, record) end end diff --git a/app/policies/user_policy.rb b/app/policies/user_policy.rb index ecf011284..fda6cd21f 100644 --- a/app/policies/user_policy.rb +++ b/app/policies/user_policy.rb @@ -32,7 +32,7 @@ class UserPolicy < ApplicationPolicy end def dashboard_show? - current_user? || user_is_admin? + current_user? || user_admin? end def moderation_routes? diff --git a/app/views/users/_mentorship.html.erb b/app/views/users/_mentorship.html.erb index 06af5da38..f341b41b6 100644 --- a/app/views/users/_mentorship.html.erb +++ b/app/views/users/_mentorship.html.erb @@ -11,7 +11,7 @@
Please share the top 3 technologies/concepts you'd be comfortable working on with your mentee, how much experience you currently have (0-10, 10 being super duper expert), and anything else you'd like us to know.
- <%= f.text_area :mentor_description, placeholder: "For example:\n\n1. Vim - 6, I love teaching people how to use vim because I really believe it increases productivity.\n\nI don't think I'd be comfortable teaching a total beginner. ", maxlength: 500 %> + <%= f.text_area :mentor_description, placeholder: "For example:\n\n1. Vim - 6, I love teaching people how to use vim because I really believe it increases productivity.\n\nI don't think I'd be comfortable teaching a total beginner. ", maxlength: 1000 %><% if @user.mentee_form_updated_at? %>
@@ -24,7 +24,7 @@
Please share the top 3 technologies/concepts you'd like to work on with your mentor, how much experience you currently have (0-10, 0 being no experience at all), and why you're interested in learning more. Please also share your general technical background and career goals.