From 8b21702d8d31cf67d1ea45a7583082b146d2eced Mon Sep 17 00:00:00 2001 From: Anusha Ranganathan <anusha@cottagelabs.com> Date: Fri, 23 Sep 2022 18:20:58 +0100 Subject: [PATCH] Also modify rake task to read collection title from config file --- hyrax/lib/tasks/create_crc_1280_collection.rake | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hyrax/lib/tasks/create_crc_1280_collection.rake b/hyrax/lib/tasks/create_crc_1280_collection.rake index 39597f84..cb7db199 100644 --- a/hyrax/lib/tasks/create_crc_1280_collection.rake +++ b/hyrax/lib/tasks/create_crc_1280_collection.rake @@ -3,13 +3,14 @@ namespace :rdms do namespace :crc_1280_collection do desc "Create CRC 1280 Collection Types and CRC 1280 Collection" task create: :environment do - collection_type = Hyrax::CollectionType.find_or_create_by(title: 'CRC 1280') + crc_collection_title = ENV.fetch('CRC_1280_COLLECTION', "CRC 1280") + collection_type = Hyrax::CollectionType.find_or_create_by(title: crc_collection_title) collection_type_gid = "gid://hyrax3-app/Hyrax::CollectionType/#{collection_type.id}" - crc_1280_collections = collection_type.collections.select{ |t| t.title == ["CRC 1280"] } + crc_1280_collections = collection_type.collections.select{ |t| t.title == [crc_collection_title] } unless crc_1280_collections.any? - collection = Hyrax.config.collection_class.create(title: ['CRC 1280'], source:[SecureRandom.uuid], collection_type_gid: collection_type_gid) + collection = Hyrax.config.collection_class.create(title: [crc_collection_title], source:[SecureRandom.uuid], collection_type_gid: collection_type_gid) admin_user = User.find_by(email: 'admin@hyrax') collection.apply_depositor_metadata(admin_user.user_key) -- GitLab