mirror of
https://github.com/internetee/registry.git
synced 2025-05-18 10:19:45 +02:00
Status attaching
This commit is contained in:
parent
d286a67cc0
commit
a72560c3d3
7 changed files with 117 additions and 4 deletions
57
app/controllers/admin/domain_statuses_controller.rb
Normal file
57
app/controllers/admin/domain_statuses_controller.rb
Normal file
|
@ -0,0 +1,57 @@
|
|||
class Admin::DomainStatusesController < ApplicationController
|
||||
before_action :set_domain
|
||||
before_action :set_domain_status, only: [:edit, :update, :destroy]
|
||||
|
||||
|
||||
def new
|
||||
@domain_status = @domain.domain_statuses.build(value: DomainStatus::OK)
|
||||
end
|
||||
|
||||
def create
|
||||
@domain_status = @domain.domain_statuses.build(domain_status_params)
|
||||
|
||||
if @domain.save
|
||||
flash[:notice] = I18n.t('shared.status_added')
|
||||
redirect_to [:admin, @domain]
|
||||
else
|
||||
flash.now[:alert] = I18n.t('shared.failed_to_add_status')
|
||||
render 'new'
|
||||
end
|
||||
end
|
||||
|
||||
def edit; end
|
||||
|
||||
def update
|
||||
if @domain_status.update(domain_status_params)
|
||||
flash[:notice] = I18n.t('shared.status_updated')
|
||||
redirect_to [:admin, @domain]
|
||||
else
|
||||
flash.now[:alert] = I18n.t('shared.failed_to_update_status')
|
||||
render 'edit'
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @domain_status.destroy
|
||||
flash[:notice] = I18n.t('shared.status_deleted')
|
||||
else
|
||||
flash[:alert] = I18n.t('shared.failed_to_delete_status')
|
||||
end
|
||||
|
||||
redirect_to [:admin, @domain]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_domain
|
||||
@domain = Domain.find(params[:domain_id])
|
||||
end
|
||||
|
||||
def set_domain_status
|
||||
@domain_status = DomainStatus.find(params[:id])
|
||||
end
|
||||
|
||||
def domain_status_params
|
||||
params.require(:domain_status).permit(:value, :description)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue