Skip to content
Snippets Groups Projects
Commit ad43d686 authored by Gyan Gupta's avatar Gyan Gupta
Browse files

allow only crc works in CRC 1280 collection

parent 15c541d9
No related tags found
1 merge request!238Allow only crc works in CRC 1280 collection
Pipeline #11717 failed
......@@ -70,6 +70,15 @@ module Hyrax
current_ability.can?(:deposit, @collection)
return t('hyrax.dashboard.my.action.add_to_collection_only') unless
member_action == "add" # should never happen
if batch_ids.present?
batch_ids.each do |batch_id|
work = ActiveFedora::Base.find(batch_id)
if work.class == Dataset && @collection.collection_type.title == 'CRC 1280'
return "Collecton #{@collection.title.first}, Only CRC 1280 works allowed"
end
end
end
end
def success_return_path
......
......@@ -13,6 +13,7 @@ class Dataset < ActiveFedora::Base
after_save :save_work_meta_json_file_to_s3
after_create :set_default_tombstone_status
after_create :register_ark
validate :validate_parent_collection
# ------ properties from core metadata ------
# property date_modified - not displayed (filled in by the system)
......@@ -127,4 +128,13 @@ class Dataset < ActiveFedora::Base
self.save
end
def validate_parent_collection
parent_collection = self.parent_collections.first
if parent_collection.present? && parent_collection.collection_type.title == 'CRC 1280'
self.errors.add("Collecton #{parent_collection.title.first}": "Only CRC 1280 works allowed")
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment