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

New account setting to override Bulkrax's default split pattern #2380

Closed
Show file tree
Hide file tree
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
13 changes: 12 additions & 1 deletion app/models/concerns/account_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module AccountSettings
setting :allow_downloads, type: 'boolean', default: true
setting :allow_signup, type: 'boolean', default: true
setting :analytics_provider, type: 'string'
setting :bulkrax_split_pattern, type: 'string', default: Bulkrax.multi_value_element_split_on.source
setting :bulkrax_validations, type: 'boolean', disabled: true
setting :cache_api, type: 'boolean', default: false
setting :contact_email, type: 'string', default: '[email protected]'
Expand Down Expand Up @@ -58,7 +59,7 @@ module AccountSettings
validates :contact_email, :oai_admin_email,
format: { with: URI::MailTo::EMAIL_REGEXP },
allow_blank: true
validate :validate_email_format, :validate_contact_emails
validate :validate_email_format, :validate_contact_emails, :validate_split_pattern_regex
validates :google_analytics_id,
format: { with: /((UA|YT|MO)-\d+-\d+|G-[A-Z0-9]{10})/i },
allow_blank: true
Expand Down Expand Up @@ -155,6 +156,16 @@ def validate_contact_emails
end
end

def validate_split_pattern_regex
return if settings['bulkrax_split_pattern'].blank?

begin
Regexp.new(settings['bulkrax_split_pattern'])
rescue RegexpError => e
errors.add(:bulkrax_split_pattern, e.message)
end
end

def initialize_settings
return true unless self.class.column_names.include?('settings')
set_smtp_settings
Expand Down
13 changes: 13 additions & 0 deletions app/parsers/bulkrax/application_parser_decorator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

module Bulkrax
module ApplicationParserDecorator
# OVERRIDE: [Bulkrax v8.3.0] Use the current Account's configured :bulkrax_split_pattern
# setting as the default split pattern when importing multi-valued fields
def multi_value_element_split_on
Regexp.new(Site.account&.settings&.dig('bulkrax_split_pattern')) || super
end
end
end

Bulkrax::ApplicationParser.singleton_class.send(:prepend, Bulkrax::ApplicationParserDecorator)
2 changes: 1 addition & 1 deletion config/locales/simple_form.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ en:
name: A single or hyphenated name used for technical aspects of the repository (e.g., "acme" or "acme-library").
gtm_id: The ID of your Google Tag Manager account
google_analytics_id: The ID of your Google Analytics account
contact_email_to: The email address that messages submitted via the contact page are sent to
weekly_email_list: List of email addresses to email the weekly report. Leave a single space between each email
monthly_email_list: List of email addresses to email the monthly report. Leave a single space between each email
yearly_email_list: List of email addresses to email the yearly report. Leave a single space between each email
Expand All @@ -35,6 +34,7 @@ en:
geonames_username: Register at http://www.geonames.org/manageaccount
file_acl: Turn off if using a file system like samba or nfs that does not support setting access control lists
ssl_configured: Set it true if using https
bulkrax_split_pattern: Default regular expression used by Bulkrax to split multiple values within the same column. <b>Omit surrounding slashes (e.g. [|;] not /[|;]/)</b>
hyku_group:
description: A brief summary of the role of the group
user:
Expand Down
Loading