Merge pull request #5725 from betagouv/fix-refacto-superadmin-rake

fix superadmin rake
This commit is contained in:
krichtof 2020-11-05 19:05:58 +01:00 committed by GitHub
commit ab62547622
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,8 +5,8 @@ namespace :superadmin do
List all super-admins
EOD
task list: :environment do
rake_puts "All Administrations:"
Administration.all.pluck(:email).each do |a|
rake_puts "All SuperAdmins:"
SuperAdmin.all.pluck(:email).each do |a|
puts a
end
end
@ -17,8 +17,8 @@ namespace :superadmin do
task :create, [:email] => :environment do |_t, args|
email = args[:email]
rake_puts "Creating Administration for #{email}"
a = Administration.new(email: email, password: Devise.friendly_token)
rake_puts "Creating SuperAdmin for #{email}"
a = SuperAdmin.new(email: email, password: Devise.friendly_token)
if a.save
rake_puts "#{a.email} created"
@ -34,8 +34,8 @@ namespace :superadmin do
EOD
task :delete, [:email] => :environment do |_t, args|
email = args[:email]
rake_puts "Deleting Administration for #{email}"
a = Administration.find_by(email: email)
rake_puts "Deleting SuperAdmin for #{email}"
a = SuperAdmin.find_by(email: email)
a.destroy
rake_puts "#{a.email} deleted"
end