This commit is contained in:
Martin Lensment 2014-09-22 15:37:48 +03:00
parent cb1a9557de
commit 93930a1243
11 changed files with 1 additions and 292 deletions

View file

@ -1,56 +0,0 @@
class Admin::DomainContactsController < ApplicationController
before_action :set_domain
before_action :set_domain_contact, only: [:destroy]
def new
@domain_contact = @domain.domain_contacts.build(contact_type: params[:type])
end
def create
@domain_contact = @domain.domain_contacts.build(domain_contact_params)
unless @domain_contact.contact
flash.now[:alert] = I18n.t('shared.contact_was_not_found')
render 'new' and return
end
@domain.adding_admin_contact = true if @domain_contact.admin?
@domain.adding_admin_contact = true if @domain_contact.tech?
if @domain.save
flash[:notice] = I18n.t('shared.contact_added')
redirect_to [:admin, @domain]
else
flash.now[:alert] = I18n.t('shared.failed_to_add_contact')
render 'new'
end
end
def destroy
@domain.domain_contacts.select { |x| x == @domain_contact }[0].mark_for_destruction
@domain.deleting_admin_contact = true if @domain_contact.admin?
@domain.deleting_tech_contact = true if @domain_contact.tech?
if @domain.save
flash[:notice] = I18n.t('shared.contact_detached')
else
flash[:alert] = @domain.errors.first[1]
end
redirect_to [:admin, @domain]
end
private
def set_domain
@domain = Domain.find(params[:domain_id])
end
def set_domain_contact
@domain_contact = DomainContact.find(params[:id])
end
def domain_contact_params
params.require(:domain_contact).permit(:contact_id, :contact_type)
end
end

View file

@ -1,56 +0,0 @@
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

View file

@ -1,60 +0,0 @@
class Admin::NameserversController < ApplicationController
before_action :set_domain
before_action :set_nameserver, only: [:edit, :update, :destroy]
def new
@nameserver = @domain.nameservers.build
end
def create
@domain.adding_nameserver = true
@nameserver = @domain.nameservers.build(nameserver_params)
if @domain.save
flash[:notice] = I18n.t('shared.nameserver_added')
redirect_to [:admin, @domain]
else
flash.now[:alert] = I18n.t('shared.failed_to_add_nameserver')
render 'new'
end
end
def edit
@nameserver = Nameserver.find(params[:id])
end
def update
if @nameserver.update(nameserver_params)
redirect_to [:admin, @domain]
else
render 'edit'
end
end
def destroy
@domain.deleting_nameserver = true
@domain.nameservers.select { |x| x == @nameserver }[0].mark_for_destruction
if @domain.save
flash[:notice] = I18n.t('shared.nameserver_deleted')
else
flash[:alert] = @domain.errors[:nameservers].first
end
redirect_to [:admin, @domain]
end
private
def set_domain
@domain = Domain.find(params[:domain_id])
end
def set_nameserver
@nameserver = Nameserver.find(params[:id])
end
def nameserver_params
params.require(:nameserver).permit(:hostname, :ipv4, :ipv6)
end
end

View file

@ -1,30 +0,0 @@
.row
.col-sm-6
%h2.text-center-xs
= "#{t('shared.new_domain_contact')}"
.col-sm-6
%h2.text-right.text-center-xs
= link_to(t('shared.back_to_domain'), [:admin, @domain], class: 'btn btn-default')
%hr
= form_for([:admin, @domain, @domain_contact]) 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 :contact_type
= f.select :contact_type, options_for_select(DomainContact::TYPES, @domain_contact.contact_type), {}, {class: 'form-control'}
.col-md-6
.form-group.has-feedback
= label_tag :contact
= text_field_tag(:contact, params[:contact], class: 'form-control js-contact-typeahead', placeholder: t('shared.contact_code'), autocomplete: 'off')
%span.glyphicon.glyphicon-ok.form-control-feedback.js-typeahead-ok.hidden
%span.glyphicon.glyphicon-remove.form-control-feedback.js-typeahead-remove
= f.hidden_field(:contact_id, class: 'js-contact-id')
.row
.col-md-12.text-right
= button_tag(t('shared.save'), class: 'btn btn-primary')

View file

@ -1,18 +0,0 @@
= 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')

View file

@ -1,9 +0,0 @@
.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'

View file

@ -1,9 +0,0 @@
.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'

View file

@ -1,28 +0,0 @@
= form_for([:admin, @domain, @nameserver]) 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
= label_tag t('shared.domain')
= text_field_tag :domain, @domain.name, disabled: true, class: 'form-control'
.col-md-6
.form-group
= f.label :hostname
= f.text_field(:hostname, class: 'form-control', autocomplete: 'off')
.row
.col-md-6
.form-group
= f.label :ipv4
= f.text_field(:ipv4, class: 'form-control', autocomplete: 'off')
.col-md-6
.form-group
= f.label :ipv6
= f.text_field(:ipv6, class: 'form-control', autocomplete: 'off')
.row
.col-md-12.text-right
= button_tag(t('shared.save'), class: 'btn btn-primary')

View file

@ -1,9 +0,0 @@
.row
.col-sm-6
%h2.text-center-xs
= "#{t('shared.edit_nameserver')}"
.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'

View file

@ -1,9 +0,0 @@
.row
.col-sm-6
%h2.text-center-xs
= "#{t('shared.new_nameserver')}"
.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'

View file

@ -6,14 +6,7 @@ Rails.application.routes.draw do
end
namespace(:admin) do
resources :domains do
resources :nameservers
resources :domain_contacts
resources :tech_contacts
resources :admin_contacts
resources :domain_statuses
end
resources :domains
resources :setting_groups
resources :registrars do
collection do