mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 10:16:01 +02:00
Move account creation from registrar model to admin/registrars controller
This commit is contained in:
parent
c1cb598da1
commit
0a6b2fe19a
2 changed files with 7 additions and 7 deletions
|
@ -17,10 +17,15 @@ class Admin::RegistrarsController < AdminController
|
||||||
def create
|
def create
|
||||||
@registrar = Registrar.new(registrar_params)
|
@registrar = Registrar.new(registrar_params)
|
||||||
|
|
||||||
if @registrar.save
|
begin
|
||||||
|
@registrar.transaction do
|
||||||
|
@registrar.save!
|
||||||
|
@registrar.accounts.create!(account_type: Account::CASH, currency: 'EUR')
|
||||||
|
end
|
||||||
|
|
||||||
flash[:notice] = I18n.t('registrar_added')
|
flash[:notice] = I18n.t('registrar_added')
|
||||||
redirect_to [:admin, @registrar]
|
redirect_to [:admin, @registrar]
|
||||||
else
|
rescue ActiveRecord::RecordInvalid
|
||||||
flash.now[:alert] = I18n.t('failed_to_add_registrar')
|
flash.now[:alert] = I18n.t('failed_to_add_registrar')
|
||||||
render 'new'
|
render 'new'
|
||||||
end
|
end
|
||||||
|
|
|
@ -57,11 +57,6 @@ class Registrar < ActiveRecord::Base
|
||||||
RegenerateRegistrarWhoisesJob.enqueue id
|
RegenerateRegistrarWhoisesJob.enqueue id
|
||||||
end
|
end
|
||||||
|
|
||||||
after_create :create_cash_account
|
|
||||||
def create_cash_account
|
|
||||||
accounts.create(account_type: Account::CASH, currency: 'EUR')
|
|
||||||
end
|
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def search_by_query(query)
|
def search_by_query(query)
|
||||||
res = search(name_or_reg_no_cont: query).result
|
res = search(name_or_reg_no_cont: query).result
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue