FIX: Clarify User.group_locked_trust_level.

* Rename User.group_locked_trust_level to User.group_granted_trust_level.

* Remove the column from users table.
This commit is contained in:
Bianca Nenciu
2018-08-25 00:41:03 +02:00
committed by Guo Xiang Tan
parent bdb8e9efdb
commit 2070edf889
9 changed files with 58 additions and 37 deletions

View File

@@ -21,6 +21,10 @@ class User < ActiveRecord::Base
include SecondFactorManager
include HasDestroyedWebHook
self.ignored_columns = %w{
group_locked_trust_level
}
has_many :posts
has_many :notifications, dependent: :destroy
has_many :topic_users, dependent: :destroy
@@ -342,6 +346,13 @@ class User < ActiveRecord::Base
find_by(username_lower: username.downcase)
end
def group_granted_trust_level
GroupUser
.where(user_id: id)
.includes(:group)
.maximum("groups.grant_trust_level")
end
def enqueue_welcome_message(message_type)
return unless SiteSetting.send_welcome_message?
Jobs.enqueue(:send_system_message, user_id: id, message_type: message_type)