Add mass actions w/ force delete to admin

This commit is contained in:
Karl Erik Õunapuu 2020-11-03 14:34:55 +02:00
parent 7a6568c34a
commit c72ca8d157
No known key found for this signature in database
GPG key ID: C9DD647298A34764
8 changed files with 76 additions and 3 deletions

21
app/models/mass_action.rb Normal file
View file

@ -0,0 +1,21 @@
class MassAction
def self.process(action_type, entries)
return process_force_delete(entries) if action_type == 'force_delete'
false
end
def self.process_force_delete(entries)
log = { ok: [], fail: [] }
entries = CSV.read(entries, headers: true)
entries.each do |e|
dn = Domain.find_by(name_puny: e['Domain name'])
log[:fail] << e['Domain name'] and next unless dn
dn.schedule_force_delete(type: :soft, notify: true)
log[:ok] << dn.name
end
log
end
end