include shares in party response for owners
This commit is contained in:
parent
e8f523a9a6
commit
50e662dc24
2 changed files with 16 additions and 1 deletions
|
|
@ -52,6 +52,21 @@ module Api
|
||||||
include_view :nested_objects # Characters, Weapons, Summons
|
include_view :nested_objects # Characters, Weapons, Summons
|
||||||
include_view :remix_metadata # Remixes, Source party
|
include_view :remix_metadata # Remixes, Source party
|
||||||
include_view :job_metadata # Accessory, Skills, Guidebooks
|
include_view :job_metadata # Accessory, Skills, Guidebooks
|
||||||
|
|
||||||
|
# Shares (only visible to owner)
|
||||||
|
field :shares, if: ->(_field_name, party, options) {
|
||||||
|
options[:current_user] && party.user_id == options[:current_user].id
|
||||||
|
} do |party|
|
||||||
|
party.party_shares.includes(:shareable).map do |share|
|
||||||
|
{
|
||||||
|
id: share.id,
|
||||||
|
shareable_type: share.shareable_type.downcase,
|
||||||
|
shareable_id: share.shareable_id,
|
||||||
|
shareable_name: share.shareable.try(:name),
|
||||||
|
created_at: share.created_at
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Primary object associations
|
# Primary object associations
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ module Api
|
||||||
end
|
end
|
||||||
|
|
||||||
if @party
|
if @party
|
||||||
render json: PartyBlueprint.render(@party, view: :full, root: :party)
|
render json: PartyBlueprint.render(@party, view: :full, root: :party, current_user: current_user)
|
||||||
else
|
else
|
||||||
render_not_found_response('project')
|
render_not_found_response('project')
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue