mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +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
|
18
app/views/admin/domain_statuses/_form.haml
Normal file
18
app/views/admin/domain_statuses/_form.haml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
= form_for([:admin, @domain, @domain_status]) do |f|
|
||||||
|
= render 'admin/shared/errors', object: @domain
|
||||||
|
= render 'admin/shared/errors', object: f.object
|
||||||
|
|
||||||
|
- if @domain.errors.any?
|
||||||
|
%hr
|
||||||
|
.row
|
||||||
|
.col-md-6
|
||||||
|
.form-group
|
||||||
|
= f.label :value
|
||||||
|
= f.select :value, options_for_select(DomainStatus::STATUSES, @domain_status.value), {}, {class: 'form-control'}
|
||||||
|
.col-md-6
|
||||||
|
.form-group
|
||||||
|
= f.label :description
|
||||||
|
= f.text_field :description, class: 'form-control', autocomplete: 'off'
|
||||||
|
.row
|
||||||
|
.col-md-12.text-right
|
||||||
|
= button_tag(t('shared.save'), class: 'btn btn-primary')
|
9
app/views/admin/domain_statuses/edit.haml
Normal file
9
app/views/admin/domain_statuses/edit.haml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
.row
|
||||||
|
.col-sm-6
|
||||||
|
%h2.text-center-xs
|
||||||
|
= "#{t('shared.edit_domain_status')}"
|
||||||
|
.col-sm-6
|
||||||
|
%h2.text-right.text-center-xs
|
||||||
|
= link_to(t('shared.back_to_domain'), [:admin, @domain], class: 'btn btn-default')
|
||||||
|
%hr
|
||||||
|
= render 'form'
|
9
app/views/admin/domain_statuses/new.haml
Normal file
9
app/views/admin/domain_statuses/new.haml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
.row
|
||||||
|
.col-sm-6
|
||||||
|
%h2.text-center-xs
|
||||||
|
= "#{t('shared.new_domain_status')}"
|
||||||
|
.col-sm-6
|
||||||
|
%h2.text-right.text-center-xs
|
||||||
|
= link_to(t('shared.back_to_domain'), [:admin, @domain], class: 'btn btn-default')
|
||||||
|
%hr
|
||||||
|
= render 'form'
|
|
@ -1,5 +1,10 @@
|
||||||
.panel.panel-default
|
- panel_class = @domain.errors.messages[:domain_statuses] ? 'panel-danger' : 'panel-default'
|
||||||
.panel-heading= t('shared.statuses')
|
.panel{class: panel_class}
|
||||||
|
.panel-heading.clearfix
|
||||||
|
.pull-left
|
||||||
|
= t('shared.statuses')
|
||||||
|
.pull-right
|
||||||
|
= link_to(t('shared.add'), new_admin_domain_domain_status_path(@domain), class: 'btn btn-primary btn-xs')
|
||||||
.table-responsive
|
.table-responsive
|
||||||
%table.table.table-hover.table-bordered.table-condensed
|
%table.table.table-hover.table-bordered.table-condensed
|
||||||
%thead
|
%thead
|
||||||
|
@ -13,5 +18,10 @@
|
||||||
%td= x.value
|
%td= x.value
|
||||||
%td= x.description
|
%td= x.description
|
||||||
%td
|
%td
|
||||||
= link_to(t('shared.edit'), root_path, class: 'btn btn-primary btn-xs')
|
= link_to(t('shared.edit'), edit_admin_domain_domain_status_path(@domain, x), class: 'btn btn-primary btn-xs')
|
||||||
= link_to(t('shared.delete'), root_path, method: :delete, data: { confirm: t('shared.are_you_sure') }, class: 'btn btn-danger btn-xs')
|
= link_to(t('shared.delete'), admin_domain_domain_status_path(@domain, x), method: :delete, data: { confirm: t('shared.are_you_sure') }, class: 'btn btn-danger btn-xs')
|
||||||
|
- if @domain.errors.messages[:domain_statuses]
|
||||||
|
%tfoot
|
||||||
|
- @domain.errors.messages[:domain_statuses].each do |x|
|
||||||
|
%tr
|
||||||
|
%td{colspan: 4}= x
|
||||||
|
|
|
@ -95,6 +95,7 @@ en:
|
||||||
auth_info:
|
auth_info:
|
||||||
wrong_pw: 'Authentication error'
|
wrong_pw: 'Authentication error'
|
||||||
domain_statuses:
|
domain_statuses:
|
||||||
|
invalid: 'Status is invalid'
|
||||||
not_found: 'Status was not found'
|
not_found: 'Status was not found'
|
||||||
taken: 'Status already exists on this domain'
|
taken: 'Status already exists on this domain'
|
||||||
domain:
|
domain:
|
||||||
|
@ -215,3 +216,11 @@ en:
|
||||||
new_admin_contact: 'New admin contact'
|
new_admin_contact: 'New admin contact'
|
||||||
contact_detached: 'Contact detached!'
|
contact_detached: 'Contact detached!'
|
||||||
failed_to_detach_contact: 'Failed to detach contact!'
|
failed_to_detach_contact: 'Failed to detach contact!'
|
||||||
|
new_domain_status: 'New domain status'
|
||||||
|
status_added: 'Status added!'
|
||||||
|
failed_to_add_status: 'Failed to add status!'
|
||||||
|
edit_domain_status: 'Edit domain status'
|
||||||
|
status_updated: 'Status updated!'
|
||||||
|
failed_to_update_status: 'Failed to update status!'
|
||||||
|
status_deleted: 'Status deleted!'
|
||||||
|
failed_to_delete_status: 'Failed to delete status!'
|
||||||
|
|
|
@ -10,6 +10,7 @@ Rails.application.routes.draw do
|
||||||
resources :nameservers
|
resources :nameservers
|
||||||
resources :tech_contacts
|
resources :tech_contacts
|
||||||
resources :admin_contacts
|
resources :admin_contacts
|
||||||
|
resources :domain_statuses
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :setting_groups
|
resources :setting_groups
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue