Skip to content

Commit

Permalink
use doi serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Oct 26, 2019
1 parent 6368a91 commit c763621
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/controllers/dois_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,9 @@ def set_doi
def set_include
if params[:include].present?
@include = params[:include].split(",").map { |i| i.downcase.underscore.to_sym }
@include = @include & [:repository, :media]
@include = @include & [:client, :media]
else
@include = [:repository, :media]
@include = [:client, :media]
end
end

Expand Down
10 changes: 9 additions & 1 deletion app/serializers/client_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class ClientSerializer
set_type :clients
set_id :uid

attributes :name, :symbol, :year, :contact_email, :alternate_name, :description, :language, :client_type, :domains, :issn, :url, :salesforce_id, :created, :updated
attributes :name, :symbol, :year, :contact_email, :alternate_name, :description, :language, :client_type, :domains, :re3data, :opendoar, :issn, :url, :salesforce_id, :created, :updated

belongs_to :provider, record_type: :providers
belongs_to :consortium, record_type: :providers, serializer: ProviderSerializer, if: Proc.new { |client| client.consortium_id }
Expand All @@ -21,4 +21,12 @@ class ClientSerializer
attribute :salesforce_id, if: Proc.new { |object, params| params[:current_ability] && params[:current_ability].can?(:read_salesforce_id, object) == true } do |object|
object.salesforce_id
end

attribute :re3data do |object|
"https://doi.org/#{object.re3data_id}" if object.re3data_id.present?
end

attribute :opendoar do |object|
"https://v2.sherpa.ac.uk/id/repository/#{object.opendoar_id}" if object.opendoar_id.present?
end
end
2 changes: 1 addition & 1 deletion app/serializers/doi_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class DoiSerializer
attributes :doi, :prefix, :suffix, :identifiers, :creators, :titles, :publisher, :container, :publication_year, :subjects, :contributors, :dates, :language, :types, :related_identifiers, :sizes, :formats, :version, :rights_list, :descriptions, :geo_locations, :funding_references, :xml, :url, :content_url, :metadata_version, :schema_version, :source, :is_active, :state, :reason, :landing_page, :created, :registered, :published, :updated
attributes :prefix, :suffix, if: Proc.new { |object, params| params && params[:detail] }

belongs_to :repository, record_type: :repositories
belongs_to :client, record_type: :clients
has_many :media, record_type: :media, id_method_name: :uid, if: Proc.new { |object, params| params && params[:detail] && !params[:is_collection]}

attribute :xml, if: Proc.new { |object, params| params && params[:detail] } do |object|
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/providers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@
put "/providers/#{provider.symbol}", params, headers

expect(last_response.status).to eq(422)
expect(json["errors"].first).to eq("source" => "ror_id", "title" => "Ror id should be a url")
expect(json["errors"].first).to eq("source" => "ror_id", "title" => "ROR ID should be a url")
end
end

Expand Down

0 comments on commit c763621

Please sign in to comment.