mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 17:01:44 +02:00
Add mass actions w/ force delete to admin
This commit is contained in:
parent
7a6568c34a
commit
c72ca8d157
8 changed files with 76 additions and 3 deletions
21
app/models/mass_action.rb
Normal file
21
app/models/mass_action.rb
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue