allow to upload user initials
This commit is contained in:
@@ -36,6 +36,14 @@ module Submitters
|
||||
user.first_name
|
||||
elsif field_name == 'last name'
|
||||
user.last_name
|
||||
elsif field['type'] == 'initials' && (initials = UserConfigs.load_initials(user))
|
||||
attachment = ActiveStorage::Attachment.find_or_create_by!(
|
||||
blob_id: initials.blob_id,
|
||||
name: 'attachments',
|
||||
record: submitter
|
||||
)
|
||||
|
||||
attachment.uuid
|
||||
elsif field['type'] == 'signature' && (signature = UserConfigs.load_signature(user))
|
||||
attachment = ActiveStorage::Attachment.find_or_create_by!(
|
||||
blob_id: signature.blob_id,
|
||||
|
||||
@@ -10,4 +10,12 @@ module UserConfigs
|
||||
|
||||
ActiveStorage::Attachment.find_by(uuid:, record: user, name: 'signature') if uuid.present?
|
||||
end
|
||||
|
||||
def load_initials(user)
|
||||
return if user.blank?
|
||||
|
||||
uuid = user.user_configs.find_or_initialize_by(key: UserConfig::INITIALS_KEY).value
|
||||
|
||||
ActiveStorage::Attachment.find_by(uuid:, record: user, name: 'initials') if uuid.present?
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user