2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-12-06 06:18:52 -05:00
|
|
|
module UserPrimaryGroupMixin
|
|
|
|
|
|
|
|
def self.included(klass)
|
|
|
|
klass.attributes :primary_group_name,
|
|
|
|
:primary_group_flair_url,
|
|
|
|
:primary_group_flair_bg_color,
|
2021-04-06 11:13:06 -04:00
|
|
|
:primary_group_flair_color,
|
|
|
|
:admin,
|
|
|
|
:moderator,
|
|
|
|
:trust_level
|
2018-12-06 06:18:52 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def primary_group_name
|
|
|
|
object&.primary_group&.name
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_primary_group_name?
|
|
|
|
object&.primary_group.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def primary_group_flair_url
|
|
|
|
object&.primary_group&.flair_url
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_primary_group_flair_url?
|
|
|
|
object&.primary_group&.flair_url.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def primary_group_flair_bg_color
|
|
|
|
object&.primary_group&.flair_bg_color
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_primary_group_flair_bg_color?
|
|
|
|
object&.primary_group&.flair_bg_color.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def primary_group_flair_color
|
|
|
|
object&.primary_group&.flair_color
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_primary_group_flair_color?
|
|
|
|
object&.primary_group&.flair_color.present?
|
|
|
|
end
|
|
|
|
|
2021-04-06 11:13:06 -04:00
|
|
|
def include_admin?
|
|
|
|
object&.admin
|
|
|
|
end
|
|
|
|
|
|
|
|
def admin
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_moderator?
|
|
|
|
object&.moderator
|
|
|
|
end
|
|
|
|
|
|
|
|
def moderator
|
|
|
|
true
|
|
|
|
end
|
2018-12-06 06:18:52 -05:00
|
|
|
end
|