Skip to content

Commit

Permalink
more fine-grained control when showing from_salesforce attribute. dat…
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jun 15, 2021
1 parent c2fb55a commit 25af2af
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app/controllers/clients_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def create
@client.send_welcome_email(responsible_id: current_user.uid)
options = {}
options[:is_collection] = false
options[:params] = { current_ability: current_ability }
options[:params] = { current_ability: current_ability, detail: true }

render json: ClientSerializer.new(@client, options).serialized_json,
status: :created
Expand All @@ -177,7 +177,7 @@ def create
def update
options = {}
options[:is_collection] = false
options[:params] = { current_ability: current_ability }
options[:params] = { current_ability: current_ability, detail: true }

if params.dig(:data, :attributes, :mode) == "transfer"
# only update provider_id
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/contacts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def create
options = {}
options[:include] = @include
options[:is_collection] = false
options[:params] = { current_ability: current_ability }
options[:params] = { current_ability: current_ability, detail: true }

render json: ContactSerializer.new(@contact, options).serialized_json,
status: :created
Expand All @@ -137,7 +137,7 @@ def update
options = {}
options[:include] = @include
options[:is_collection] = false
options[:params] = { current_ability: current_ability }
options[:params] = { current_ability: current_ability, detail: true }

render json: ContactSerializer.new(@contact, options).serialized_json,
status: :ok
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/providers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def create
options = {}
options[:include] = @include
options[:is_collection] = false
options[:params] = { current_ability: current_ability }
options[:params] = { current_ability: current_ability, detail: true }

render json: ProviderSerializer.new(@provider, options).serialized_json,
status: :ok
Expand All @@ -272,7 +272,7 @@ def update
options = {}
options[:include] = @include
options[:is_collection] = false
options[:params] = { current_ability: current_ability }
options[:params] = { current_ability: current_ability, detail: true }

render json: ProviderSerializer.new(@provider, options).serialized_json,
status: :ok
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/contact_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ContactSerializer
attribute :from_salesforce,
if:
Proc.new { |object, params|
params[:current_ability] &&
params[:detail] && params[:current_ability] &&
params[:current_ability].can?(:read_salesforce_id, object) ==
true
},
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/provider_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ class ProviderSerializer
attribute :from_salesforce,
if:
Proc.new { |object, params|
params[:current_ability] &&
params[:detail] && params[:current_ability] &&
params[:current_ability].can?(:read_salesforce_id, object) ==
true
},
Expand Down
2 changes: 1 addition & 1 deletion app/serializers/repository_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class RepositorySerializer
attribute :from_salesforce,
if:
Proc.new { |object, params|
params[:current_ability] &&
params[:detail] && params[:current_ability] &&
params[:current_ability].can?(:read_salesforce_id, object) ==
true
},
Expand Down

0 comments on commit 25af2af

Please sign in to comment.