From 89e8b002945d1dae004c81b6a950fd26898c3d73 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Fri, 24 May 2019 07:19:47 +0200 Subject: [PATCH] use role_member with provider. datacite/bracco#195 --- app/controllers/providers_controller.rb | 6 +++--- app/serializers/provider_serializer.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/providers_controller.rb b/app/controllers/providers_controller.rb index 12fa048a8..030fb6f70 100644 --- a/app/controllers/providers_controller.rb +++ b/app/controllers/providers_controller.rb @@ -25,7 +25,7 @@ def index elsif params[:ids].present? response = Provider.find_by_id(params[:ids], page: page, sort: sort) else - response = Provider.query(params[:query], year: params[:year], region: params[:region], organization_type: params[:organization_type], focus_area: params[:focus_area], page: page, sort: sort) + response = Provider.query(params[:query], year: params[:year], region: params[:region], organization_type: params[:organization_type], focus_area: params[:focus_area], all_members: params[:all_members], page: page, sort: sort) end begin @@ -221,7 +221,7 @@ def destroy # Use callbacks to share common setup or constraints between actions. def set_provider - @provider = Provider.unscoped.where("allocator.role_name IN ('ROLE_FOR_PROFIT_PROVIDER', 'ROLE_CONTRACTUAL_PROVIDER', 'ROLE_CONSORTIUM_LEAD' , 'ROLE_ALLOCATOR', 'ROLE_ADMIN')").where(deleted_at: nil).where(symbol: params[:id]).first + @provider = Provider.unscoped.where("allocator.role_name IN ('ROLE_FOR_PROFIT_PROVIDER', 'ROLE_CONTRACTUAL_PROVIDER', 'ROLE_CONSORTIUM_LEAD' , 'ROLE_ALLOCATOR', 'ROLE_ADMIN', 'ROLE_MEMBER')").where(deleted_at: nil).where(symbol: params[:id]).first fail ActiveRecord::RecordNotFound unless @provider.present? end @@ -244,7 +244,7 @@ def safe_params "votingContact",{ "votingContact": [:email, "givenName", "familyName"]} ], keys: { - "organizationType" => :organization_type, "focusArea" => :focus_area, "contactName" => :contact_name, "contactEmail" => :contact_email, :country => :country_code, "isActive" => :is_active, "passwordInput" => :password_input, "billingInformation" => :billing_information , "postCode" => :post_code, "rorId" => :ror_id, "twitterHandle" =>:twitter_handle, "roleName" =>:role_name, + "organizationType" => :organization_type, "focusArea" => :focus_area, "contactName" => :contact_name, "contactEmail" => :contact_email, :country => :country_code, "isActive" => :is_active, "passwordInput" => :password_input, "billingInformation" => :billing_information , "postCode" => :post_code, "rorId" => :ror_id, "twitterHandle" => :twitter_handle, "roleName" => :role_name, "technicalContact" => :technical_contact, "secondaryBillingContact" => :secondary_billing_contact, "billingContact" => :billing_contact, diff --git a/app/serializers/provider_serializer.rb b/app/serializers/provider_serializer.rb index 304856ce8..0b59af7c9 100644 --- a/app/serializers/provider_serializer.rb +++ b/app/serializers/provider_serializer.rb @@ -5,7 +5,7 @@ class ProviderSerializer set_id :uid # cache_options enabled: true, cache_length: 24.hours ### we cannot filter if we cache - attributes :name, :symbol, :website, :contact_name, :contact_email, :phone, :description, :region, :country, :logo_url, :organization_type, :focus_area, :is_active, :has_password, :joined, :twitter_handle, :billing_information, :ror_id, :technical_contact,:billing_contact, :secondary_billing_contact, :service_contact, :voting_contact, :created, :updated + attributes :name, :symbol, :website, :contact_name, :contact_email, :phone, :description, :region, :country, :logo_url, :member_type, :organization_type, :focus_area, :is_active, :has_password, :joined, :twitter_handle, :billing_information, :ror_id, :technical_contact, :billing_contact, :secondary_billing_contact, :service_contact, :voting_contact, :created, :updated has_many :clients, record_type: :clients has_many :prefixes, record_type: :prefixes