mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 18:56:05 +02:00
Fix price checking for all the domains
This commit is contained in:
parent
7d2aad570e
commit
a954f3c8e6
5 changed files with 51 additions and 34 deletions
|
@ -10,26 +10,24 @@ class Registrar
|
|||
|
||||
def bulk_renew
|
||||
authorize! :manage, :repp
|
||||
@expire_date = params[:expire_date].to_date
|
||||
@domains = domains_by_date(@expire_date)
|
||||
@period = params[:period]
|
||||
set_form_data
|
||||
|
||||
if domain_ids_for_bulk_renew.present?
|
||||
domains = Epp::Domain.where(id: domain_ids_for_bulk_renew).to_a
|
||||
task = Domains::BulkRenew::Start.run(domains: domains,
|
||||
period_element: @period,
|
||||
registrar: current_registrar_user.registrar)
|
||||
flash[:notice] = if task.valid?
|
||||
t(:bulk_renew_completed)
|
||||
else
|
||||
task.errors.full_messages.join(' and ')
|
||||
end
|
||||
task = renew_task(domains)
|
||||
flash[:notice] = flash_message(task)
|
||||
end
|
||||
render file: 'registrar/bulk_change/new', locals: { active_tab: :bulk_renew }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_form_data
|
||||
@expire_date = params[:expire_date].to_date
|
||||
@domains = domains_by_date(@expire_date)
|
||||
@period = params[:period]
|
||||
end
|
||||
|
||||
def available_contacts
|
||||
current_registrar_user.registrar.contacts.order(:name).pluck(:name, :code)
|
||||
end
|
||||
|
@ -47,7 +45,21 @@ class Registrar
|
|||
end
|
||||
|
||||
def domain_ids_for_bulk_renew
|
||||
params.dig('domain_ids')&.reject{ |id| id.blank? }
|
||||
params.dig('domain_ids')&.reject { |id| id.blank? }
|
||||
end
|
||||
|
||||
def renew_task(domains)
|
||||
Domains::BulkRenew::Start.run(domains: domains,
|
||||
period_element: @period,
|
||||
registrar: current_registrar_user.registrar)
|
||||
end
|
||||
|
||||
def flash_message(task)
|
||||
if task.valid?
|
||||
t(:bulk_renew_completed)
|
||||
else
|
||||
task.errors.full_messages.join(' and ')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue