mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Design
This commit is contained in:
parent
7b88e6e028
commit
eac302bafb
6 changed files with 51 additions and 7 deletions
|
@ -6,13 +6,23 @@ class Admin::NameserversController < ApplicationController
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@domain = Domain.find(params[:domain_id])
|
@domain = Domain.find(params[:domain_id])
|
||||||
if @domain.nameservers.create(nameserver_params)
|
@nameserver = @domain.nameservers.build(nameserver_params)
|
||||||
|
|
||||||
|
if @domain.save
|
||||||
redirect_to [:admin, @domain]
|
redirect_to [:admin, @domain]
|
||||||
else
|
else
|
||||||
render 'new'
|
render 'new'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
# TODO: Refactor this
|
||||||
|
@nameserver = Nameserver.find(params[:id])
|
||||||
|
@domain = @nameserver.domains.first
|
||||||
|
@nameserver.destroy
|
||||||
|
redirect_to [:admin, @domain]
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def nameserver_params
|
def nameserver_params
|
||||||
|
|
|
@ -7,12 +7,12 @@ class Nameserver < ActiveRecord::Base
|
||||||
|
|
||||||
belongs_to :registrar
|
belongs_to :registrar
|
||||||
|
|
||||||
has_many :domain_nameservers
|
has_many :domain_nameservers, dependent: :delete_all
|
||||||
has_many :domains, through: :domain_nameservers
|
has_many :domains, through: :domain_nameservers
|
||||||
|
|
||||||
validates :hostname, format: { with: /\A(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])\z/ }
|
validates :hostname, format: { with: /\A(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])\z/ }
|
||||||
validates :ipv4, format: { with: /\A(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\z/, allow_nil: true }
|
validates :ipv4, format: { with: /\A(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\z/, allow_blank: true }
|
||||||
validates :ipv6, format: { with: /(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/, allow_nil: true }
|
validates :ipv6, format: { with: /(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/, allow_blank: true }
|
||||||
|
|
||||||
def epp_code_map
|
def epp_code_map
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
%td= x.ipv6
|
%td= x.ipv6
|
||||||
%td
|
%td
|
||||||
= link_to(t('shared.edit'), root_path, class: 'btn btn-primary btn-xs')
|
= link_to(t('shared.edit'), root_path, 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, x], method: :delete, data: { confirm: t('shared.are_you_sure') }, class: 'btn btn-danger btn-xs')
|
||||||
- if @domain.errors.messages[:nameservers]
|
- if @domain.errors.messages[:nameservers]
|
||||||
%tfoot
|
%tfoot
|
||||||
- @domain.errors.messages[:nameservers].each do |x|
|
- @domain.errors.messages[:nameservers].each do |x|
|
||||||
|
|
|
@ -1,3 +1,30 @@
|
||||||
|
%h2= t('shared.new_nameserver')
|
||||||
|
%hr
|
||||||
= form_for([:admin, @domain, @nameserver]) do |f|
|
= form_for([:admin, @domain, @nameserver]) do |f|
|
||||||
= f.text_field :hostname
|
= render 'admin/shared/errors', object: @domain
|
||||||
= f.button 'save'
|
= 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')
|
||||||
|
|
5
app/views/admin/shared/_errors.haml
Normal file
5
app/views/admin/shared/_errors.haml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
- if object.errors.any?
|
||||||
|
- object.errors.each do |attr, err|
|
||||||
|
- next if attr == :epp_errors
|
||||||
|
= err
|
||||||
|
%br
|
|
@ -81,6 +81,7 @@ en:
|
||||||
admin_contacts:
|
admin_contacts:
|
||||||
out_of_range: 'Admin contacts count must be between 1 - infinity'
|
out_of_range: 'Admin contacts count must be between 1 - infinity'
|
||||||
nameservers:
|
nameservers:
|
||||||
|
invalid: 'Nameserver is invalid'
|
||||||
out_of_range: 'Nameservers count must be between %{min}-%{max}'
|
out_of_range: 'Nameservers count must be between %{min}-%{max}'
|
||||||
not_found: 'Nameserver was not found'
|
not_found: 'Nameserver was not found'
|
||||||
taken: 'Nameserver already exists on this domain'
|
taken: 'Nameserver already exists on this domain'
|
||||||
|
@ -188,3 +189,4 @@ en:
|
||||||
registrar_name: 'Registrar name'
|
registrar_name: 'Registrar name'
|
||||||
contact_code: 'Contact code'
|
contact_code: 'Contact code'
|
||||||
add: 'Add'
|
add: 'Add'
|
||||||
|
domain: 'Domain'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue