Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ahamelers committed Jun 29, 2023
1 parent 44fbd9e commit d93dbc1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function PrelimArticle({
{
htmlId: 'publication',
labelText: 'Journal name',
isRequired: false,
isRequired: true,
}
}
/>
Expand Down
40 changes: 23 additions & 17 deletions app/models/stash_datacite/resource/dataset_validations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,29 @@ def loose_errors
err.flatten
end

def article_id
err = []

if @resource.identifier.import_info != 'other' && @resource.identifier.publication_name.blank?
err << ErrorItem.new(message: 'Fill in the {journal of the related publication}',
page: metadata_page(@resource),
ids: ['publication'])
end

journal = " from #{@resource.identifier.publication_name}" if @resource.identifier.publication_name.present?

if @resource.identifier.import_info == 'published' && @resource.identifier.publication_article_doi.blank?
err << ErrorItem.new(message: "Fill in {a correctly formatted DOI} for the article#{journal}",
page: metadata_page(@resource),
ids: %w[primary_article_doi])
elsif @resource.identifier.import_info == 'manuscript' && @resource.identifier.manuscript_number.blank?
err << ErrorItem.new(message: "Fill in the {manuscript number} for the article#{journal}",
page: metadata_page(@resource),
ids: ['msId'])
end
err
end

def title
if @resource.title.blank?
return ErrorItem.new(message: 'Fill in a {dataset title}',
Expand Down Expand Up @@ -167,23 +190,6 @@ def abstract
[]
end

def article_id
return [] unless @resource.identifier.publication_name.present? &&
@resource.identifier.manuscript_number.blank? &&
@resource.identifier.publication_article_doi.blank?

if @resource.related_identifiers.where(work_type: 'primary_article').count.positive? # has primary, but not doi
ErrorItem.new(message: "Fill in {a correctly formatted DOI} for your article from #{@resource.identifier
.publication_name}",
page: metadata_page(@resource),
ids: %w[primary_article_doi])
else
ErrorItem.new(message: "Fill in a {manuscript number or DOI} for the article from #{@resource.identifier.publication_name}",
page: metadata_page(@resource),
ids: %w[msid primary_article_doi])
end
end

def s3_error_uploads
return [] if @resource.submitted?

Expand Down
1 change: 1 addition & 0 deletions spec/support/helpers/dataset_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def fill_required_metadata
# make sure we're on the right page
navigate_to_metadata

choose('choose_other')
fill_in 'title', with: Faker::Lorem.sentence
fill_in_author
fill_in_research_domain
Expand Down

0 comments on commit d93dbc1

Please sign in to comment.