diff --git a/README.md b/README.md index c942fc960..d0861d125 100644 --- a/README.md +++ b/README.md @@ -30,11 +30,11 @@ bundle exec rspec ``` Note when using a fresh test database you will need to instantiate the test db with: + ```bash bundle exec rake db:create RAILS_ENV=test ``` - Follow along via [Github Issues](https://github.com/datacite/lupo/issues). ### Note on Patches/Pull Requests diff --git a/app/controllers/providers_controller.rb b/app/controllers/providers_controller.rb index 283654650..33fc2b08a 100644 --- a/app/controllers/providers_controller.rb +++ b/app/controllers/providers_controller.rb @@ -156,7 +156,7 @@ def show providers = provider_count(consortium_id: nil) clients = client_count(provider_id: nil) dois = doi_count(provider_id: nil) - elsif @provider.member_type == "consortium" + elsif @provider.member_type == "consortium_member" providers = provider_count(consortium_id: params[:id]) clients = client_count(consortium_id: params[:id]) dois = doi_count(consortium_id: params[:id]) @@ -184,9 +184,27 @@ def create authorize! :create, @provider if @provider.save + if @provider.symbol == "ADMIN" + providers = provider_count(consortium_id: nil) + clients = client_count(provider_id: nil) + dois = doi_count(provider_id: nil) + elsif @provider.member_type == "consortium_member" + providers = provider_count(consortium_id: params[:id]) + clients = client_count(consortium_id: params[:id]) + dois = doi_count(consortium_id: params[:id]) + else + providers = nil + clients = client_count(provider_id: params[:id]) + dois = doi_count(provider_id: params[:id]) + end + options = {} options[:include] = @include options[:is_collection] = false + options[:meta] = { + providers: providers, + clients: clients, + dois: dois }.compact options[:params] = { current_ability: current_ability } render json: ProviderSerializer.new(@provider, options).serialized_json, status: :ok @@ -204,7 +222,7 @@ def update providers = provider_count(consortium_id: nil) clients = client_count(provider_id: nil) dois = doi_count(provider_id: nil) - elsif @provider.member_type == "consortium" + elsif @provider.member_type == "consortium_member" providers = provider_count(consortium_id: params[:id]) clients = client_count(consortium_id: params[:id]) dois = doi_count(consortium_id: params[:id])