Merge branch 'master' of github.com:internetee/registry

Conflicts:
	app/models/contact.rb
	db/schema.rb
This commit is contained in:
Andres Keskküla 2014-10-15 11:06:31 +03:00
commit 897ead3391
66 changed files with 1173 additions and 409 deletions

View file

@ -11,6 +11,7 @@ class Admin::ContactVersionsController < AdminController
end
private
def set_contact
@contact = Contact.find(params[:id])
end

View file

@ -11,6 +11,7 @@ class Admin::DomainVersionsController < AdminController
end
private
def set_domain
@domain = Domain.find(params[:id])
end

View file

@ -53,6 +53,7 @@ class Admin::UsersController < AdminController
end
def user_params
params.require(:user).permit(:username, :password, :identity_code, :email, :registrar_id, :admin, :registrar_typeahead, :country_id)
params.require(:user).permit(:username, :password, :identity_code, :email, :registrar_id,
:admin, :registrar_typeahead, :country_id)
end
end

View file

@ -12,10 +12,12 @@ class Client::ContactsController < ClientController
end
def show
# rubocop: disable Style/GuardClause
if @contact.registrar != current_registrar
flash[:alert] = I18n.t('shared.authentication_error')
redirect_to client_contacts_path
end
# rubocop: enable Style/GuardClause
end
def create
@ -27,7 +29,7 @@ class Client::ContactsController < ClientController
redirect_to [:client, @contact]
else
flash[:alert] = I18n.t('shared.failed_to_create_contact')
render "new"
render 'new'
end
end
@ -63,7 +65,7 @@ class Client::ContactsController < ClientController
end
def contact_params
params.require(:contact).permit( :email, :phone, :fax, :ident_type, :ident, :auth_info, :name, :org_name,
params.require(:contact).permit(:email, :phone, :fax, :ident_type, :ident, :auth_info, :name, :org_name,
address_attributes: [:city, :street, :zip, :street2, :street3, :country_id])
end
end

View file

@ -12,6 +12,8 @@ class Client::DomainTransfersController < ClientController
@domain_transfer = DomainTransfer.new
end
# rubocop: disable Metrics/PerceivedComplexity
# rubocop: disable Metrics/CyclomaticComplexity
def create
@domain_transfer = @domain.pending_transfer
@ -36,6 +38,8 @@ class Client::DomainTransfersController < ClientController
redirect_to [:client, @domain_transfer]
end
end
# rubocop: enable Metrics/PerceivedComplexity
# rubocop: enable Metrics/CyclomaticComplexity
def approve
if can? :approve_as_client, @domain_transfer
@ -63,6 +67,8 @@ class Client::DomainTransfersController < ClientController
}
end
# rubocop: disable Metrics/PerceivedComplexity
# rubocop: disable Metrics/CyclomaticComplexity
def set_domain
@domain_transfer = DomainTransfer.new
@domain = Domain.find_by(name: params[:domain_name])
@ -81,4 +87,6 @@ class Client::DomainTransfersController < ClientController
render 'new'
end
end
# rubocop: enbale Metrics/PerceivedComplexity
# rubocop: enable Metrics/CyclomaticComplexity
end

View file

@ -14,7 +14,9 @@ module Epp::Common
end
def proxy
@svTRID = "ccReg-#{'%010d' % rand(10**10)}"
# rubocop: disable Style/VariableName
@svTRID = "ccReg-#{format('%010d', rand(10**10))}"
# rubocop: enable Style/VariableName
send(params[:command])
end
@ -46,7 +48,10 @@ module Epp::Common
end
# for debugging
@errors << { code: '1', msg: 'handle_errors was executed when there were actually no errors' } if @errors.blank?
@errors << {
code: '1',
msg: 'handle_errors was executed when there were actually no errors'
} if @errors.blank?
@errors.uniq!
@ -60,7 +65,10 @@ module Epp::Common
def xml_attrs_present?(ph, attributes)
attributes.each do |x|
epp_errors << { code: '2003', msg: I18n.t('errors.messages.required_parameter_missing', key: x.last) } unless has_attribute(ph, x)
epp_errors << {
code: '2003',
msg: I18n.t('errors.messages.required_parameter_missing', key: x.last)
} unless has_attribute(ph, x)
end
epp_errors.empty?
end
@ -68,24 +76,27 @@ module Epp::Common
def xml_attrs_array_present?(array_ph, attributes)
[array_ph].flatten.each do |ph|
attributes.each do |x|
unless has_attribute(ph, x)
epp_errors << { code: '2003', msg: I18n.t('errors.messages.required_parameter_missing', key: x.last) }
end
next if has_attribute(ph, x)
epp_errors << {
code: '2003',
msg: I18n.t('errors.messages.required_parameter_missing', key: x.last)
}
end
end
epp_errors.empty?
end
# rubocop: disable Style/PredicateName
def has_attribute(ph, path)
path.reduce(ph) do |location, key|
location.respond_to?(:keys) ? location[key] : nil
end
end
# rubocop: enable Style/PredicateName
def validate_request
validation_method = "validate_#{OBJECT_TYPES[params_hash['epp']['xmlns:ns2']]}_#{params[:command]}_request"
if respond_to?(validation_method, true)
handle_errors and return unless send(validation_method)
end
return unless respond_to?(validation_method, true)
handle_errors and return unless send(validation_method)
end
end

View file

@ -1,6 +1,6 @@
class SessionsController < Devise::SessionsController
def create
#TODO: Create ID Card login here:
# TODO: Create ID Card login here:
# this is just testing config
# if Rails.env.development? || Rails.env.test?
@user = User.find_by(username: 'gitlab') if params[:gitlab]
@ -10,8 +10,7 @@ class SessionsController < Devise::SessionsController
session[:current_user_registrar_id] = Registrar.first.id if @user.admin?
flash[:notice] = I18n.t('shared.welcome')
sign_in_and_redirect @user, :event => :authentication
return
sign_in_and_redirect @user, event: :authentication
# end
end