Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add update_schema_version before_save action #1192

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/models/doi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def validate_publisher_obj?(doi)
before_validation :update_identifiers
before_validation :update_types
before_save :set_defaults, :save_metadata
before_save :update_schema_version
before_create { self.created = Time.zone.now.utc.iso8601 }

FIELD_OF_SCIENCE_SCHEME = "Fields of Science and Technology (FOS)"
Expand Down Expand Up @@ -2332,6 +2333,12 @@ def update_types
).compact
end

def update_schema_version
if current_metadata.present? && current_metadata.valid?
self.schema_version = current_metadata.namespace
end
end

def update_publisher
case publisher_before_type_cast
when Hash
Expand Down