diff --git a/app/controllers/admin/domains_controller.rb b/app/controllers/admin/domains_controller.rb new file mode 100644 index 000000000..6c6f570ea --- /dev/null +++ b/app/controllers/admin/domains_controller.rb @@ -0,0 +1,5 @@ +class Admin::DomainsController < ApplicationController + def index + @domains = Domain.all + end +end diff --git a/app/helpers/epp/domains_helper.rb b/app/helpers/epp/domains_helper.rb index bbfb9854f..e5b89c5b6 100644 --- a/app/helpers/epp/domains_helper.rb +++ b/app/helpers/epp/domains_helper.rb @@ -83,7 +83,8 @@ module Epp::DomainsHelper ## CREATE def validate_domain_create_request @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 def domain_create_params diff --git a/app/models/contact.rb b/app/models/contact.rb index d06af8cb5..ee290a58b 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -113,6 +113,10 @@ class Contact < ActiveRecord::Base } end + def to_s + name + end + class << self def extract_attributes(ph, type = :create) contact_hash = { diff --git a/app/models/domain.rb b/app/models/domain.rb index 34b98eecb..89fb90c70 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -327,6 +327,10 @@ class Domain < ActiveRecord::Base ## SHARED + def to_s + name + end + def generate_auth_info begin self.auth_info = SecureRandom.hex diff --git a/app/models/registrar.rb b/app/models/registrar.rb index d7f38202f..1b30024b4 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -3,4 +3,8 @@ class Registrar < ActiveRecord::Base has_many :domains has_many :ns_sets has_many :epp_users + + def to_s + name + end end diff --git a/app/views/admin/domains/index.haml b/app/views/admin/domains/index.haml new file mode 100644 index 000000000..de65e281c --- /dev/null +++ b/app/views/admin/domains/index.haml @@ -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') diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 69f8b0b72..608d2c81e 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -28,7 +28,7 @@ %li = link_to t('shared.registrars'), root_path %li - = link_to t('shared.domains'), root_path + = link_to t('shared.domains'), admin_domains_path %li.dropdown %a.dropdown-toggle{"data-toggle" => "dropdown", href: "#"} = t('shared.settings') diff --git a/config/locales/en.yml b/config/locales/en.yml index ba07d4428..948ab46f5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -20,6 +20,17 @@ # available at http://guides.rubyonrails.org/i18n.html. 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: errors: models: @@ -127,8 +138,12 @@ en: domains: 'Domains' epp_users: 'EPP Users' 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' edit_settings: 'Edit settings' setting_group: 'Setting group' setting: 'Setting' + registrar: 'Registrar' + owner: 'Owner' diff --git a/config/routes.rb b/config/routes.rb index b0f0ea48b..1afe04a4b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,6 +6,7 @@ Rails.application.routes.draw do end namespace(:admin) do + resources :domains resources :setting_groups end @@ -13,7 +14,7 @@ Rails.application.routes.draw do # See how all your routes lay out with "rake routes". # You can have the root of your site routed with "root" - root 'admin/setting_groups#index' + root 'admin/domains#index' # Example of regular route: # get 'products/:id' => 'catalog#view' diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index c693d52da..2210dbdb6 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -218,10 +218,7 @@ describe 'EPP Domain', epp: true do response = epp_request(xml, :xml) expect(response[:results][0][:result_code]).to eq('2003') - expect(response[:results][0][:msg]).to eq('Required parameter missing: contact') - - expect(response[:results][1][:result_code]).to eq('2003') - expect(response[:results][1][:msg]).to eq('Required parameter missing: registrant') + expect(response[:results][0][:msg]).to eq('Required parameter missing: registrant') end it 'does not create domain without nameservers' do diff --git a/spec/features/domain_management_spec.rb b/spec/features/domain_management_spec.rb new file mode 100644 index 000000000..b630a9468 --- /dev/null +++ b/spec/features/domain_management_spec.rb @@ -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