2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-12-06 19:18:52 +08:00
|
|
|
module UserPrimaryGroupMixin
|
|
|
|
def self.included(klass)
|
|
|
|
klass.attributes :primary_group_name,
|
2021-07-08 15:46:21 +08:00
|
|
|
:flair_name,
|
|
|
|
:flair_url,
|
|
|
|
:flair_bg_color,
|
|
|
|
:flair_color,
|
2021-04-06 23:13:06 +08:00
|
|
|
:admin,
|
|
|
|
:moderator,
|
|
|
|
:trust_level
|
2018-12-06 19:18:52 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def primary_group_name
|
|
|
|
object&.primary_group&.name
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_primary_group_name?
|
|
|
|
object&.primary_group.present?
|
|
|
|
end
|
|
|
|
|
2021-07-08 15:46:21 +08:00
|
|
|
def flair_name
|
|
|
|
object&.flair_group&.name
|
2018-12-06 19:18:52 +08:00
|
|
|
end
|
|
|
|
|
2021-07-08 15:46:21 +08:00
|
|
|
def include_flair_group_name?
|
|
|
|
object&.flair_group.present?
|
2018-12-06 19:18:52 +08:00
|
|
|
end
|
|
|
|
|
2021-07-08 15:46:21 +08:00
|
|
|
def flair_url
|
|
|
|
object&.flair_group&.flair_url
|
2018-12-06 19:18:52 +08:00
|
|
|
end
|
|
|
|
|
2021-07-08 15:46:21 +08:00
|
|
|
def include_flair_url?
|
|
|
|
object&.flair_group&.flair_url.present?
|
2018-12-06 19:18:52 +08:00
|
|
|
end
|
|
|
|
|
2021-07-08 15:46:21 +08:00
|
|
|
def flair_bg_color
|
|
|
|
object&.flair_group&.flair_bg_color
|
2018-12-06 19:18:52 +08:00
|
|
|
end
|
|
|
|
|
2021-07-08 15:46:21 +08:00
|
|
|
def include_flair_bg_color?
|
|
|
|
object&.flair_group&.flair_bg_color.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def flair_color
|
|
|
|
object&.flair_group&.flair_color
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_flair_color?
|
|
|
|
object&.flair_group&.flair_color.present?
|
2018-12-06 19:18:52 +08:00
|
|
|
end
|
|
|
|
|
2021-04-06 23:13:06 +08:00
|
|
|
def include_admin?
|
|
|
|
object&.admin
|
|
|
|
end
|
|
|
|
|
|
|
|
def admin
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_moderator?
|
|
|
|
object&.moderator
|
|
|
|
end
|
|
|
|
|
|
|
|
def moderator
|
|
|
|
true
|
|
|
|
end
|
2018-12-06 19:18:52 +08:00
|
|
|
end
|