mirror of
https://github.com/discourse/discourse.git
synced 2024-12-05 14:23:39 +08:00
3abc542e63
Followup to c03f83bbea
.
The `flair_group_id` parameter is now required to show the flair, and this serializer was missing that detail.
This also fixes a typo in the `include_flair_group_name?` method.
80 lines
1.4 KiB
Ruby
80 lines
1.4 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module UserPrimaryGroupMixin
|
|
def self.included(klass)
|
|
klass.attributes :primary_group_name,
|
|
:flair_name,
|
|
:flair_url,
|
|
:flair_bg_color,
|
|
:flair_color,
|
|
:flair_group_id,
|
|
:admin,
|
|
:moderator,
|
|
:trust_level
|
|
end
|
|
|
|
def primary_group_name
|
|
object&.primary_group&.name
|
|
end
|
|
|
|
def include_primary_group_name?
|
|
object&.primary_group.present?
|
|
end
|
|
|
|
def flair_name
|
|
object&.flair_group&.name
|
|
end
|
|
|
|
def include_flair_name?
|
|
object&.flair_group.present?
|
|
end
|
|
|
|
def flair_url
|
|
object&.flair_group&.flair_url
|
|
end
|
|
|
|
def include_flair_url?
|
|
object&.flair_group&.flair_url.present?
|
|
end
|
|
|
|
def flair_bg_color
|
|
object&.flair_group&.flair_bg_color
|
|
end
|
|
|
|
def include_flair_bg_color?
|
|
object&.flair_group&.flair_bg_color.present?
|
|
end
|
|
|
|
def flair_group_id
|
|
object&.flair_group_id
|
|
end
|
|
|
|
def include_flair_group_id?
|
|
object&.flair_group_id.present?
|
|
end
|
|
|
|
def flair_color
|
|
object&.flair_group&.flair_color
|
|
end
|
|
|
|
def include_flair_color?
|
|
object&.flair_group&.flair_color.present?
|
|
end
|
|
|
|
def include_admin?
|
|
object&.admin
|
|
end
|
|
|
|
def admin
|
|
true
|
|
end
|
|
|
|
def include_moderator?
|
|
object&.moderator
|
|
end
|
|
|
|
def moderator
|
|
true
|
|
end
|
|
end
|