mail -> email
This commit is contained in:
parent
59c0374ec8
commit
1a644a5159
1 changed files with 9 additions and 9 deletions
|
@ -3,17 +3,17 @@ require Rails.root.join("lib", "tasks", "task_helper")
|
||||||
namespace :support do
|
namespace :support do
|
||||||
desc <<~EOD
|
desc <<~EOD
|
||||||
Give procedure #PROCEDURE_ID a new owner.
|
Give procedure #PROCEDURE_ID a new owner.
|
||||||
The owner can be specified with NEW_OWNER_ID or NEW_OWNER_MAIL.
|
The new owner can be specified with NEW_OWNER_ID or NEW_OWNER_EMAIL.
|
||||||
EOD
|
EOD
|
||||||
task transfer_procedure_ownership: :environment do
|
task transfer_procedure_ownership: :environment do
|
||||||
new_owner_id = ENV['NEW_OWNER_ID']
|
new_owner_id = ENV['NEW_OWNER_ID']
|
||||||
new_owner_mail = ENV['NEW_OWNER_MAIL']
|
new_owner_email = ENV['NEW_OWNER_EMAIL']
|
||||||
|
|
||||||
new_owner = nil
|
new_owner = nil
|
||||||
if new_owner_id.present?
|
if new_owner_id.present?
|
||||||
new_owner = Administrateur.find(new_owner_id)
|
new_owner = Administrateur.find(new_owner_id)
|
||||||
elsif new_owner_mail.present?
|
elsif new_owner_email.present?
|
||||||
new_owner = Administrateur.find_by(email: new_owner_mail)
|
new_owner = Administrateur.find_by('LOWER(email) = LOWER(?)', new_owner_email)
|
||||||
end
|
end
|
||||||
|
|
||||||
if new_owner.blank?
|
if new_owner.blank?
|
||||||
|
@ -33,15 +33,15 @@ namespace :support do
|
||||||
end
|
end
|
||||||
|
|
||||||
desc <<~EOD
|
desc <<~EOD
|
||||||
Delete the user account for a given USER_MAIL.
|
Delete the user account for a given USER_EMAIL.
|
||||||
Only works if the user has no dossier where the instruction has started.
|
Only works if the user has no dossier where the instruction has started.
|
||||||
EOD
|
EOD
|
||||||
task delete_user_account: :environment do
|
task delete_user_account: :environment do
|
||||||
user_mail = ENV['USER_MAIL']
|
user_email = ENV['USER_EMAIL']
|
||||||
if user_mail.nil?
|
if user_email.nil?
|
||||||
fail "Must specify a USER_MAIL"
|
fail "Must specify a USER_EMAIL"
|
||||||
end
|
end
|
||||||
user = User.find_by(email: user_mail)
|
user = User.find_by(email: user_email)
|
||||||
if user.dossiers.state_instruction_commencee.any?
|
if user.dossiers.state_instruction_commencee.any?
|
||||||
fail "Cannot delete this user because instruction has started for some dossiers"
|
fail "Cannot delete this user because instruction has started for some dossiers"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue