MERGE: merged staging at 3235647, resolved merge conflict

This commit is contained in:
Matt Farnsworth 2015-10-30 16:12:20 +02:00
commit 45588dc72a
78 changed files with 308808 additions and 421 deletions

View file

@ -3,13 +3,15 @@ class Admin::ReservedDomainsController < AdminController
def index
rd = ReservedDomain.first_or_initialize
@reserved_domains = rd.names.to_yaml
rd.names = nil if rd.names.blank?
@reserved_domains = rd.names.to_yaml.gsub(/---.?\n/, '').gsub(/\.\.\..?\n/, '')
end
def create
@reserved_domains = params[:reserved_domains]
begin
params[:reserved_domains] = "---\n" if params[:reserved_domains].blank?
names = YAML.load(params[:reserved_domains])
fail if names == false
rescue

View file

@ -116,7 +116,7 @@ class Epp::SessionsController < EppController
def connection_limit_ok?
return true if Rails.env.test? || Rails.env.development?
c = EppSession.where(
'registrar_id = ? AND updated_at >= ?', @api_user.registrar_id, Time.zone.now - 5.minutes
'registrar_id = ? AND updated_at >= ?', @api_user.registrar_id, Time.zone.now - 1.second
).count
return false if c >= 4

View file

@ -150,6 +150,10 @@ class EppController < ApplicationController
end
@errors.uniq!
logger.error "\nFOLLOWING ERRORS OCCURRED ON EPP QUERY:"
logger.error @errors.inspect
logger.error "\n"
# Requested by client, ticket #2688
# Known issues: error request is exactly 1 second slower and server can handle less load

View file

@ -1,6 +1,6 @@
class Registrar::DomainsController < Registrar::DeppController # EPP controller
before_action :init_domain, except: :new
before_action :init_contacts_autocomplete_map, only: [:new, :edit, :create, :update]
helper_method :contacts
# rubocop: disable Metrics/PerceivedComplexity
# rubocop: disable Metrics/CyclomaticComplexity
@ -138,17 +138,27 @@ class Registrar::DomainsController < Registrar::DeppController # EPP controller
end
end
def search_contacts
authorize! :create, Depp::Domain
scope = current_user.registrar.contacts.limit(10)
if params[:query].present?
escaped_str = ActiveRecord::Base.connection.quote_string params[:query]
scope = scope.where("name ilike '%#{escaped_str}%' OR code ilike '%#{escaped_str}%' ")
end
render json: scope.pluck(:name, :code).map { |c| {display_key: "#{c.second} #{c.first}", value: c.second} }
end
private
def init_domain
@domain = Depp::Domain.new(current_user: depp_current_user)
end
def init_contacts_autocomplete_map
@contacts_autocomplete_map ||=
current_user.registrar.contacts.pluck(:name, :code).map { |c| ["#{c.second} #{c.first}", c.second] }
# @priv_contacts_autocomplete_map ||=
# current_user.registrar.priv_contacts.pluck(:name, :code).map { |c| ["#{c.second} #{c.first}", c.second] }
def contacts
current_user.registrar.contacts
end
def normalize_search_parameters