mirror of
https://github.com/internetee/registry.git
synced 2025-07-26 04:28:27 +02:00
Add deposits controller
This commit is contained in:
parent
5c0e2be387
commit
13c94aeb1c
10 changed files with 88 additions and 4 deletions
26
app/controllers/registrar/deposits_controller.rb
Normal file
26
app/controllers/registrar/deposits_controller.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
class Registrar::DepositsController < RegistrarController
|
||||
authorize_resource class: false
|
||||
|
||||
def new
|
||||
@deposit = Deposit.new
|
||||
end
|
||||
|
||||
def create
|
||||
@deposit = Deposit.new(deposit_params.merge(registrar: current_user.registrar))
|
||||
@invoice = @deposit.issue_prepayment_invoice
|
||||
|
||||
if @invoice
|
||||
flash[:notice] = t('please_pay_the_following_invoice')
|
||||
redirect_to [:registrar, @invoice]
|
||||
else
|
||||
flash[:alert] = t('failed_to_create_record')
|
||||
render 'new'
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def deposit_params
|
||||
params.require(:deposit).permit(:amount, :description)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue