diff --git a/app/controllers/registrar/keyrelays_controller.rb b/app/controllers/registrar/keyrelays_controller.rb index a6d6789c7..13c480524 100644 --- a/app/controllers/registrar/keyrelays_controller.rb +++ b/app/controllers/registrar/keyrelays_controller.rb @@ -9,8 +9,8 @@ class Registrar::KeyrelaysController < Registrar::DeppController # EPP controlle @data = keyrelay.keyrelay(params) if response_ok? - flash[:epp_results] = [{ 'code' => '1000', 'msg' => 'Command completed successfully' }] - redirect_to keyrelay_path + flash[:epp_results] = [{ 'code' => '1000', 'msg' => 'Command completed successfully', 'show' => true }] + redirect_to registrar_keyrelay_path else render 'show' end diff --git a/app/models/depp/keyrelay.rb b/app/models/depp/keyrelay.rb index 9476014f0..f4e609c05 100644 --- a/app/models/depp/keyrelay.rb +++ b/app/models/depp/keyrelay.rb @@ -30,13 +30,17 @@ module Depp authInfo: { pw: { value: params['password'] } }, - expiry: { - relative: { value: params['expiry_relative'] }, - absolute: { value: params['expiry_absolute'] } - } + expiry: expiry(params['expiry']) }, custom_params) current_user.request(xml) end + + def expiry(value) + ISO8601::Duration.new(value) + { relative: { value: value } } + rescue => _e + { absolute: { value: value } } + end end end diff --git a/app/validators/duration_iso8601_validator.rb b/app/validators/duration_iso8601_validator.rb index c92f9f505..f1b1c3fa8 100644 --- a/app/validators/duration_iso8601_validator.rb +++ b/app/validators/duration_iso8601_validator.rb @@ -6,7 +6,7 @@ class DurationIso8601Validator < ActiveModel::EachValidator class << self def validate(value) - return false if value.blank? + return true if value.blank? return true if value.empty? begin diff --git a/app/views/registrar/keyrelays/show.haml b/app/views/registrar/keyrelays/show.haml index d0f3aa8c5..40b40db04 100644 --- a/app/views/registrar/keyrelays/show.haml +++ b/app/views/registrar/keyrelays/show.haml @@ -7,57 +7,50 @@ .col-md-3.control-label = label_tag :domain_name, t(:domain_name), class: 'required' .col-md-7 - = text_field_tag :domain_name, params[:domain_name], + = text_field_tag :domain_name, params[:domain_name], class: 'form-control', autocomplete: 'off', required: true .form-group .col-md-3.control-label = label_tag :password, t(:password), class: 'required' .col-md-7 - = text_field_tag :password, params[:password], + = text_field_tag :password, params[:password], class: 'form-control', autocomplete: 'off', required: true .form-group .col-md-3.control-label - = label_tag :expiry_relative, t(:expiry_relative), class: 'required' + = label_tag :expiry, t(:expiry), class: 'required' .col-md-7 - = text_field_tag :expiry_relative, params[:expiry_relative], - class: 'form-control', autocomplete: 'off', required: true - - .form-group - .col-md-3.control-label - = label_tag :expiry_absolute, t(:expiry_absolute), class: 'required' - .col-md-7 - = text_field_tag :expiry_absolute, params[:expiry_absolute], + = text_field_tag :expiry, params[:expiry], class: 'form-control', autocomplete: 'off', required: true .form-group .col-md-3.control-label = label_tag :key_data_flags, t(:flag), class: 'required' .col-md-7 - = select_tag :key_data_flags, + = select_tag :key_data_flags, options_for_select(Depp::Dnskey::FLAGS, params['key_data_flags']), {class: 'form-control'} .form-group .col-md-3.control-label = label_tag :key_data_protocol, t(:protocol), class: 'required' .col-md-7 - = select_tag :key_data_protocol, - options_for_select(Depp::Dnskey::PROTOCOLS, params['key_data_protocol']), + = select_tag :key_data_protocol, + options_for_select(Depp::Dnskey::PROTOCOLS, params['key_data_protocol']), {class: 'form-control'} .form-group .col-md-3.control-label = label_tag :key_data_alg, t(:algorithm), class: 'required' .col-md-7 - = select_tag :key_data_alg, + = select_tag :key_data_alg, options_for_select(Depp::Dnskey::ALGORITHMS, params['key_data_alg']), {class: 'form-control'} .form-group .col-md-3.control-label = label_tag :key_data_public_key, t(:public_key), class: 'required' .col-md-7 - = text_field_tag :key_data_public_key, params['key_data_public_key'], + = text_field_tag :key_data_public_key, params['key_data_public_key'], class: 'form-control', required: true .form-group diff --git a/app/views/registrar/shared/_epp_results.haml b/app/views/registrar/shared/_epp_results.haml index 5645c5063..4dfaadaed 100644 --- a/app/views/registrar/shared/_epp_results.haml +++ b/app/views/registrar/shared/_epp_results.haml @@ -18,10 +18,12 @@ - if flash[:epp_results] - flash[:epp_results].each do |x| - - next if success_codes.include?(x['code']) + - next if success_codes.include?(x['code']) && x['show'] != true + - c = 'alert-danger' + - c = 'alert-success' if success_codes.include?(x['code']) .row .col-md-12 - %p{class: "alert alert-danger"} + %p{class: "alert #{c}"} = x['msg'].split('[').first - if x['value'].present? = " - #{x['value']}" diff --git a/config/locales/en.yml b/config/locales/en.yml index dc013d9d3..dcaa69043 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -731,3 +731,4 @@ en: client: 'Client' you_have_a_new_invoice: 'You have a new invoice.' sincerely: 'Sincerely' + expiry: 'Expiry' diff --git a/spec/models/keyrelay_spec.rb b/spec/models/keyrelay_spec.rb index 040567c0e..5cd5ff9ef 100644 --- a/spec/models/keyrelay_spec.rb +++ b/spec/models/keyrelay_spec.rb @@ -16,7 +16,6 @@ describe Keyrelay do @keyrelay.errors.full_messages.should match_array([ "Auth info pw Password is missing", "Domain is missing", - "Expiry relative Expiry relative must be compatible to ISO 8601", "Key data alg Algorithm is missing", "Key data flags Flag is missing", "Key data protocol Protocol is missing",