Domain list for admin

This commit is contained in:
Martin Lensment 2014-09-05 12:16:02 +03:00
parent 238be6d59e
commit 8531e50474
11 changed files with 81 additions and 7 deletions

View file

@ -0,0 +1,5 @@
class Admin::DomainsController < ApplicationController
def index
@domains = Domain.all
end
end

View file

@ -83,7 +83,8 @@ module Epp::DomainsHelper
## CREATE ## CREATE
def validate_domain_create_request def validate_domain_create_request
@ph = params_hash['epp']['command']['create']['create'] @ph = params_hash['epp']['command']['create']['create']
xml_attrs_present?(@ph, [['name'], ['ns'], ['contact'], ['registrant']]) # TODO: Verify contact presence if registrant is juridical
xml_attrs_present?(@ph, [['name'], ['ns'], ['registrant']])
end end
def domain_create_params def domain_create_params

View file

@ -113,6 +113,10 @@ class Contact < ActiveRecord::Base
} }
end end
def to_s
name
end
class << self class << self
def extract_attributes(ph, type = :create) def extract_attributes(ph, type = :create)
contact_hash = { contact_hash = {

View file

@ -327,6 +327,10 @@ class Domain < ActiveRecord::Base
## SHARED ## SHARED
def to_s
name
end
def generate_auth_info def generate_auth_info
begin begin
self.auth_info = SecureRandom.hex self.auth_info = SecureRandom.hex

View file

@ -3,4 +3,8 @@ class Registrar < ActiveRecord::Base
has_many :domains has_many :domains
has_many :ns_sets has_many :ns_sets
has_many :epp_users has_many :epp_users
def to_s
name
end
end end

View file

@ -0,0 +1,24 @@
%h2= t('shared.domains')
%hr
.row
.col-md-12
.table-responsive
%table.table.table-striped.table-bordered.table-condensed
%tr
%th{class: 'col-xs-2'}
= t('shared.name')
%th{class: 'col-xs-2'}
= t('shared.registrar')
%th{class: 'col-xs-2'}
= t('shared.owner')
%th{class: 'col-xs-1'}
= t('shared.valid_to')
%th{class: 'col-xs-1'}
= t('shared.action')
- @domains.each do |x|
%tr
%td= link_to(x, admin_domain_path(x))
%td= link_to(x.registrar, root_path) if x.registrar
%td= link_to(x.owner_contact, root_path)
%td= l(x.valid_to, format: :short)
%td= link_to(t('shared.edit'), edit_admin_domain_path(x), class: 'btn btn-primary btn-xs')

View file

@ -28,7 +28,7 @@
%li %li
= link_to t('shared.registrars'), root_path = link_to t('shared.registrars'), root_path
%li %li
= link_to t('shared.domains'), root_path = link_to t('shared.domains'), admin_domains_path
%li.dropdown %li.dropdown
%a.dropdown-toggle{"data-toggle" => "dropdown", href: "#"} %a.dropdown-toggle{"data-toggle" => "dropdown", href: "#"}
= t('shared.settings') = t('shared.settings')

View file

@ -20,6 +20,17 @@
# available at http://guides.rubyonrails.org/i18n.html. # available at http://guides.rubyonrails.org/i18n.html.
en: en:
time:
formats:
default: "%d. %B %Y, %H:%M"
longer: "%a, %e. %b %Y, %H:%M"
long: "%A, %e. %B %Y, %H:%M"
short: "%d.%m.%y, %H:%M"
date:
formats:
year_and_month: "%Y %B"
activerecord: activerecord:
errors: errors:
models: models:
@ -127,8 +138,12 @@ en:
domains: 'Domains' domains: 'Domains'
epp_users: 'EPP Users' epp_users: 'EPP Users'
registrars: 'Registrars' registrars: 'Registrars'
valid_to: 'Valid to'
name: 'Name'
transfer_can_be_approved_only_by_current_registrar: 'Transfer can be approved only by current domain registrar' transfer_can_be_approved_only_by_current_registrar: 'Transfer can be approved only by current domain registrar'
edit_settings: 'Edit settings' edit_settings: 'Edit settings'
setting_group: 'Setting group' setting_group: 'Setting group'
setting: 'Setting' setting: 'Setting'
registrar: 'Registrar'
owner: 'Owner'

View file

@ -6,6 +6,7 @@ Rails.application.routes.draw do
end end
namespace(:admin) do namespace(:admin) do
resources :domains
resources :setting_groups resources :setting_groups
end end
@ -13,7 +14,7 @@ Rails.application.routes.draw do
# See how all your routes lay out with "rake routes". # See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root" # You can have the root of your site routed with "root"
root 'admin/setting_groups#index' root 'admin/domains#index'
# Example of regular route: # Example of regular route:
# get 'products/:id' => 'catalog#view' # get 'products/:id' => 'catalog#view'

View file

@ -218,10 +218,7 @@ describe 'EPP Domain', epp: true do
response = epp_request(xml, :xml) response = epp_request(xml, :xml)
expect(response[:results][0][:result_code]).to eq('2003') expect(response[:results][0][:result_code]).to eq('2003')
expect(response[:results][0][:msg]).to eq('Required parameter missing: contact') expect(response[:results][0][:msg]).to eq('Required parameter missing: registrant')
expect(response[:results][1][:result_code]).to eq('2003')
expect(response[:results][1][:msg]).to eq('Required parameter missing: registrant')
end end
it 'does not create domain without nameservers' do it 'does not create domain without nameservers' do

View file

@ -0,0 +1,19 @@
require 'rails_helper'
feature 'Domain management', type: :feature do
background do
Fabricate(:domain_validation_setting_group)
Fabricate.times(4, :domain)
end
scenario 'User sees domains', js: true do
visit root_path
click_on 'Domains'
Domain.all.each do |x|
expect(page).to have_link(x)
expect(page).to have_link(x.registrar)
expect(page).to have_link(x.owner_contact)
end
end
end