Improve keyrelay registrar

This commit is contained in:
Martin Lensment 2015-04-24 13:25:52 +03:00
parent cdc93a570f
commit b1714f4b1f
7 changed files with 25 additions and 26 deletions

View file

@ -9,8 +9,8 @@ class Registrar::KeyrelaysController < Registrar::DeppController # EPP controlle
@data = keyrelay.keyrelay(params) @data = keyrelay.keyrelay(params)
if response_ok? if response_ok?
flash[:epp_results] = [{ 'code' => '1000', 'msg' => 'Command completed successfully' }] flash[:epp_results] = [{ 'code' => '1000', 'msg' => 'Command completed successfully', 'show' => true }]
redirect_to keyrelay_path redirect_to registrar_keyrelay_path
else else
render 'show' render 'show'
end end

View file

@ -30,13 +30,17 @@ module Depp
authInfo: { authInfo: {
pw: { value: params['password'] } pw: { value: params['password'] }
}, },
expiry: { expiry: expiry(params['expiry'])
relative: { value: params['expiry_relative'] },
absolute: { value: params['expiry_absolute'] }
}
}, custom_params) }, custom_params)
current_user.request(xml) current_user.request(xml)
end end
def expiry(value)
ISO8601::Duration.new(value)
{ relative: { value: value } }
rescue => _e
{ absolute: { value: value } }
end
end end
end end

View file

@ -6,7 +6,7 @@ class DurationIso8601Validator < ActiveModel::EachValidator
class << self class << self
def validate(value) def validate(value)
return false if value.blank? return true if value.blank?
return true if value.empty? return true if value.empty?
begin begin

View file

@ -7,57 +7,50 @@
.col-md-3.control-label .col-md-3.control-label
= label_tag :domain_name, t(:domain_name), class: 'required' = label_tag :domain_name, t(:domain_name), class: 'required'
.col-md-7 .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 class: 'form-control', autocomplete: 'off', required: true
.form-group .form-group
.col-md-3.control-label .col-md-3.control-label
= label_tag :password, t(:password), class: 'required' = label_tag :password, t(:password), class: 'required'
.col-md-7 .col-md-7
= text_field_tag :password, params[:password], = text_field_tag :password, params[:password],
class: 'form-control', autocomplete: 'off', required: true class: 'form-control', autocomplete: 'off', required: true
.form-group .form-group
.col-md-3.control-label .col-md-3.control-label
= label_tag :expiry_relative, t(:expiry_relative), class: 'required' = label_tag :expiry, t(:expiry), class: 'required'
.col-md-7 .col-md-7
= text_field_tag :expiry_relative, params[:expiry_relative], = text_field_tag :expiry, params[:expiry],
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],
class: 'form-control', autocomplete: 'off', required: true class: 'form-control', autocomplete: 'off', required: true
.form-group .form-group
.col-md-3.control-label .col-md-3.control-label
= label_tag :key_data_flags, t(:flag), class: 'required' = label_tag :key_data_flags, t(:flag), class: 'required'
.col-md-7 .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'} options_for_select(Depp::Dnskey::FLAGS, params['key_data_flags']), {class: 'form-control'}
.form-group .form-group
.col-md-3.control-label .col-md-3.control-label
= label_tag :key_data_protocol, t(:protocol), class: 'required' = label_tag :key_data_protocol, t(:protocol), class: 'required'
.col-md-7 .col-md-7
= select_tag :key_data_protocol, = select_tag :key_data_protocol,
options_for_select(Depp::Dnskey::PROTOCOLS, params['key_data_protocol']), options_for_select(Depp::Dnskey::PROTOCOLS, params['key_data_protocol']),
{class: 'form-control'} {class: 'form-control'}
.form-group .form-group
.col-md-3.control-label .col-md-3.control-label
= label_tag :key_data_alg, t(:algorithm), class: 'required' = label_tag :key_data_alg, t(:algorithm), class: 'required'
.col-md-7 .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'} options_for_select(Depp::Dnskey::ALGORITHMS, params['key_data_alg']), {class: 'form-control'}
.form-group .form-group
.col-md-3.control-label .col-md-3.control-label
= label_tag :key_data_public_key, t(:public_key), class: 'required' = label_tag :key_data_public_key, t(:public_key), class: 'required'
.col-md-7 .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 class: 'form-control', required: true
.form-group .form-group

View file

@ -18,10 +18,12 @@
- if flash[:epp_results] - if flash[:epp_results]
- flash[:epp_results].each do |x| - 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 .row
.col-md-12 .col-md-12
%p{class: "alert alert-danger"} %p{class: "alert #{c}"}
= x['msg'].split('[').first = x['msg'].split('[').first
- if x['value'].present? - if x['value'].present?
= " - #{x['value']}" = " - #{x['value']}"

View file

@ -731,3 +731,4 @@ en:
client: 'Client' client: 'Client'
you_have_a_new_invoice: 'You have a new invoice.' you_have_a_new_invoice: 'You have a new invoice.'
sincerely: 'Sincerely' sincerely: 'Sincerely'
expiry: 'Expiry'

View file

@ -16,7 +16,6 @@ describe Keyrelay do
@keyrelay.errors.full_messages.should match_array([ @keyrelay.errors.full_messages.should match_array([
"Auth info pw Password is missing", "Auth info pw Password is missing",
"Domain is missing", "Domain is missing",
"Expiry relative Expiry relative must be compatible to ISO 8601",
"Key data alg Algorithm is missing", "Key data alg Algorithm is missing",
"Key data flags Flag is missing", "Key data flags Flag is missing",
"Key data protocol Protocol is missing", "Key data protocol Protocol is missing",