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

Conflicts:
	app/models/domain.rb
	app/models/epp/epp_domain.rb
	config/locales/en.yml
	spec/epp/domain_spec.rb
This commit is contained in:
Martin Lensment 2014-10-13 10:37:26 +03:00
commit ee2d93128c
50 changed files with 528 additions and 201 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

View file

@ -1,5 +1,5 @@
module ApplicationHelper
def coffee_script_tag(&block)
content_tag(:script, CoffeeScript.compile(capture(&block)).html_safe, :type => 'text/javascript')
content_tag(:script, CoffeeScript.compile(capture(&block)).html_safe, type: 'text/javascript')
end
end

View file

@ -20,6 +20,7 @@ module Epp::ContactsHelper
end
end
# rubocop:disable Metrics/CyclomaticComplexity
def delete_contact
@contact = find_contact
handle_errors(@contact) and return unless owner?
@ -28,6 +29,7 @@ module Epp::ContactsHelper
render '/epp/contacts/delete'
end
# rubocop:enable Metrics/CyclomaticComplexity
def check_contact
ph = params_hash['epp']['command']['check']['check']
@ -54,11 +56,11 @@ module Epp::ContactsHelper
## CREATE
def validate_contact_create_request
@ph = params_hash['epp']['command']['create']['create']
xml_attrs_present?(@ph, [ %w(authInfo pw), %w(postalInfo)])
xml_attrs_present?(@ph, [%w(authInfo pw), %w(postalInfo)])
return epp_errors.empty? unless @ph['postalInfo'].is_a?(Hash) || @ph['postalInfo'].is_a?(Array)
#(epp_errors << Address.validate_postal_info_types(parsed_frame)).flatten!
# (epp_errors << Address.validate_postal_info_types(parsed_frame)).flatten!
xml_attrs_array_present?(@ph['postalInfo'], [%w(name), %w(addr city), %w(addr cc)])
end
@ -114,7 +116,7 @@ module Epp::ContactsHelper
def owner?
return false unless find_contact
#return true if current_epp_user.registrar == find_contact.created_by.try(:registrar)
# return true if current_epp_user.registrar == find_contact.created_by.try(:registrar)
return true if @contact.registrar == current_epp_user.registrar
epp_errors << { code: '2201', msg: t('errors.messages.epp_authorization_error') }
false

View file

@ -8,12 +8,12 @@ module Epp::DomainsHelper
if @domain.errors.any?
handle_errors(@domain)
raise ActiveRecord::Rollback and return
fail ActiveRecord::Rollback and return
end
unless @domain.save
handle_errors(@domain)
raise ActiveRecord::Rollback and return
fail ActiveRecord::Rollback and return
end
render '/epp/domains/create'
@ -44,6 +44,7 @@ module Epp::DomainsHelper
render '/epp/domains/info'
end
# rubocop:disable Metrics/CyclomaticComplexity
def update_domain
Epp::EppDomain.transaction do
@domain = find_domain
@ -58,17 +59,18 @@ module Epp::DomainsHelper
if @domain.errors.any?
handle_errors(@domain)
raise ActiveRecord::Rollback and return
fail ActiveRecord::Rollback and return
end
unless @domain.save
handle_errors(@domain)
raise ActiveRecord::Rollback and return
fail ActiveRecord::Rollback and return
end
render '/epp/domains/success'
end
end
# rubocop:enable Metrics/CyclomaticComplexity
def transfer_domain
@domain = find_domain(secure: false)
@ -79,6 +81,7 @@ module Epp::DomainsHelper
render '/epp/domains/transfer'
end
# rubocop:disable Metrics/CyclomaticComplexity
def delete_domain
@domain = find_domain
@ -88,6 +91,7 @@ module Epp::DomainsHelper
render '/epp/domains/success'
end
# rubocop:enbale Metrics/CyclomaticComplexity
### HELPER METHODS ###
@ -166,12 +170,20 @@ module Epp::DomainsHelper
domain = Epp::EppDomain.find_by(name: @ph[:name])
unless domain
epp_errors << { code: '2303', msg: I18n.t('errors.messages.epp_domain_not_found'), value: { obj: 'name', val: @ph[:name] } }
epp_errors << {
code: '2303',
msg: I18n.t('errors.messages.epp_domain_not_found'),
value: { obj: 'name', val: @ph[:name] }
}
return nil
end
if domain.registrar != current_epp_user.registrar && secure[:secure] == true
epp_errors << { code: '2302', msg: I18n.t('errors.messages.domain_exists_but_belongs_to_other_registrar'), value: { obj: 'name', val: @ph[:name] } }
epp_errors << {
code: '2302',
msg: I18n.t('errors.messages.domain_exists_but_belongs_to_other_registrar'),
value: { obj: 'name', val: @ph[:name] }
}
return nil
end

View file

@ -1,15 +1,21 @@
class Ability
include CanCan::Ability
# rubocop: disable Metrics/MethodLength
# rubocop: disable Metrics/CyclomaticComplexity
def initialize(user)
alias_action :create, :read, :update, :destroy, :to => :crud
alias_action :create, :read, :update, :destroy, to: :crud
user ||= User.new
if Rails.env.production?
case REGISTRY_ENV
when :client
when :eedirekt
can :view, :eedirekt
can :create, :session
admin = false
when :registrar
can :view, :registrar
can :create, :session
admin = false
when :admin
@ -32,7 +38,7 @@ class Ability
can :read, DomainTransfer, transfer_to_id: user.registrar.id
can :read, DomainTransfer, transfer_from_id: user.registrar.id
can :approve_as_client, DomainTransfer,
transfer_from_id: user.registrar.id, status: DomainTransfer::PENDING
transfer_from_id: user.registrar.id, status: DomainTransfer::PENDING
end
# Define abilities for the passed in user here. For example:
@ -62,4 +68,6 @@ class Ability
# See the wiki for details:
# https://github.com/ryanb/cancan/wiki/Defining-Abilities
end
# rubocop: enable Metrics/MethodLength
# rubocop: enable Metrics/CyclomaticComplexity
end

View file

@ -13,19 +13,27 @@ class Address < ActiveRecord::Base
has_paper_trail class_name: 'AddressVersion'
class << self
# def validate_postal_info_types(parsed_frame)
# errors, used = [], []
# parsed_frame.css('postalInfo').each do |pi|
# attr = pi.attributes['type'].try(:value)
# errors << { code: 2003, msg: I18n.t('errors.messages.attr_missing', key: 'type') } and next unless attr
# unless TYPES.include?(attr)
# errors << { code: 2005, msg: I18n.t('errors.messages.invalid_type'), value: { obj: 'type', val: attr } }
# next
# end
# errors << { code: 2005, msg: I18n.t('errors.messages.repeating_postal_info') } and next if used.include?(attr)
# used << attr
# end; errors
# end
# def validate_postal_info_types(parsed_frame)
# errors, used = [], []
# parsed_frame.css('postalInfo').each do |pi|
# attr = pi.attributes['type'].try(:value)
# errors << {
# code: 2003, msg: I18n.t('errors.messages.attr_missing', key: 'type')
# } and next unless attr
# unless TYPES.include?(attr)
# errors << {
# code: 2005,
# msg: I18n.t('errors.messages.invalid_type'), value: { obj: 'type', val: attr }
# }
# next
# end
# errors << {
# code: 2005,
# msg: I18n.t('errors.messages.repeating_postal_info')
# } and next if used.include?(attr)
# used << attr
# end; errors
# end
def extract_attributes(ah)
address_hash = {}
@ -36,10 +44,10 @@ class Address < ActiveRecord::Base
private
# def local?(postal_info)
# return :local_address_attributes if postal_info[:type] == LOCAL_TYPE_SHORT
# :international_address_attributes
# end
# def local?(postal_info)
# return :local_address_attributes if postal_info[:type] == LOCAL_TYPE_SHORT
# :international_address_attributes
# end
def addr_hash_from_params(addr)
return {} if addr.nil?

View file

@ -25,7 +25,7 @@ module EppErrors
values.each do |err|
code, value = find_epp_code_and_value(err)
next unless code
epp_errors << { code: code, msg: err, value: value}
epp_errors << { code: code, msg: err, value: value }
end
epp_errors
end
@ -33,11 +33,11 @@ module EppErrors
def collect_child_errors(key)
macro = self.class.reflect_on_association(key).macro
multi = [:has_and_belongs_to_many, :has_many]
single = [:belongs_to, :has_one]
# single = [:belongs_to, :has_one]
epp_errors = []
send(key).each do |x|
x.errors.messages.each do |key, values|
x.errors.messages.each do |_key, values|
epp_errors << x.collect_parent_errors(values)
end
end if multi.include?(macro)

View file

@ -18,7 +18,5 @@ module UserEvents
def epp_user_events(id)
where(whodunnit: "#{id}-EppUser")
end
end
end

View file

@ -5,37 +5,37 @@ class Contact < ActiveRecord::Base
include EppErrors
#has_one :local_address, dependent: :destroy
#has_one :international_address, dependent: :destroy
# has_one :local_address, dependent: :destroy
# has_one :international_address, dependent: :destroy
has_one :address, dependent: :destroy
has_one :disclosure, class_name: 'ContactDisclosure'
has_many :domain_contacts
has_many :domains, through: :domain_contacts
# TODO remove the x_by
# TODO: remove the x_by
belongs_to :created_by, class_name: 'EppUser', foreign_key: :created_by_id
belongs_to :updated_by, class_name: 'EppUser', foreign_key: :updated_by_id
belongs_to :registrar
accepts_nested_attributes_for :address, :disclosure
validates :code, :phone, :email, :ident, :address, :registrar,presence: true
validates :code, :phone, :email, :ident, :address, :registrar, presence: true
validate :ident_must_be_valid
#validate :presence_of_one_address
# validate :presence_of_one_address
validates :phone, format: /\+[0-9]{1,3}\.[0-9]{1,14}?/ # /\+\d{3}\.\d+/
validates :email, format: /@/
validates :code, uniqueness: { message: :epp_id_taken }
delegate :country, to: :address#, prefix: true
delegate :city, to: :address#, prefix: true
delegate :street, to: :address#, prefix: true
delegate :zip, to: :address#, prefix: true
delegate :country, to: :address # , prefix: true
delegate :city, to: :address # , prefix: true
delegate :street, to: :address # , prefix: true
delegate :zip, to: :address # , prefix: true
#scopes
# scopes
scope :current_registrars, ->(id) { where(registrar_id: id) }
# archiving
has_paper_trail class_name: 'ContactVersion'
@ -97,7 +97,6 @@ class Contact < ActiveRecord::Base
# should use only in transaction
def destroy_and_clean
if relations_with_domain?
errors.add(:domains, :exist)
return false
@ -161,6 +160,4 @@ class Contact < ActiveRecord::Base
res.reduce([]) { |o, v| o << { id: v[:id], display_key: "#{v.name} (#{v.code})" } }
end
end
private
end

View file

@ -5,5 +5,4 @@ class ContactVersion < PaperTrail::Version
self.table_name = :contact_versions
self.sequence_name = :contact_version_id_seq
end

View file

@ -1,6 +1,6 @@
class Domain < ActiveRecord::Base
# TODO whois requests ip whitelist for full info for own domains and partial info for other domains
# TODO most inputs should be trimmed before validatation, probably some global logic?
# TODO: whois requests ip whitelist for full info for own domains and partial info for other domains
# TODO: most inputs should be trimmed before validatation, probably some global logic?
paginates_per 10 # just for showoff
belongs_to :registrar
@ -9,27 +9,27 @@ class Domain < ActiveRecord::Base
has_many :domain_contacts, dependent: :delete_all
accepts_nested_attributes_for :domain_contacts, allow_destroy: true
has_many :tech_contacts, -> do
where(domain_contacts: { contact_type: DomainContact::TECH })
end, through: :domain_contacts, source: :contact
has_many :tech_contacts,
-> { where(domain_contacts: { contact_type: DomainContact::TECH }) },
through: :domain_contacts, source: :contact
has_many :admin_contacts, -> do
where(domain_contacts: { contact_type: DomainContact::ADMIN })
end, through: :domain_contacts, source: :contact
has_many :admin_contacts,
-> { where(domain_contacts: { contact_type: DomainContact::ADMIN }) },
through: :domain_contacts, source: :contact
has_many :nameservers, dependent: :delete_all
accepts_nested_attributes_for :nameservers, allow_destroy: true,
reject_if: proc { |attrs| attrs[:hostname].blank? }
reject_if: proc { |attrs| attrs[:hostname].blank? }
has_many :domain_statuses, dependent: :delete_all
accepts_nested_attributes_for :domain_statuses, allow_destroy: true,
reject_if: proc { |attrs| attrs[:value].blank? }
reject_if: proc { |attrs| attrs[:value].blank? }
has_many :domain_transfers, dependent: :delete_all
has_many :dnskeys, dependent: :delete_all
# accepts_nested_attributes_for :delegation_signers, allow_destroy: true,
# reject_if: proc { |attrs| attrs[:public_key].blank? }
accepts_nested_attributes_for :dnskeys, allow_destroy: true,
reject_if: proc { |attrs| attrs[:public_key].blank? }
delegate :code, to: :owner_contact, prefix: true
delegate :email, to: :owner_contact, prefix: true
@ -64,9 +64,9 @@ class Domain < ActiveRecord::Base
def name=(value)
value.strip!
write_attribute(:name, SimpleIDN.to_unicode(value))
write_attribute(:name_puny, SimpleIDN.to_ascii(value))
write_attribute(:name_dirty, value)
self[:name] = SimpleIDN.to_unicode(value)
self[:name_puny] = SimpleIDN.to_ascii(value)
self[:name_dirty] = value
end
def owner_contact_typeahead
@ -118,7 +118,7 @@ class Domain < ActiveRecord::Base
def validate_nameserver_ips
nameservers.each do |ns|
next if !ns.hostname.end_with?(name)
next unless ns.hostname.end_with?(name)
next if ns.ipv4.present?
errors.add(:nameservers, :invalid) if errors[:nameservers].blank?
ns.errors.add(:ipv4, :blank)
@ -214,11 +214,13 @@ class Domain < ActiveRecord::Base
name
end
# rubocop:disable Lint/Loop
def generate_auth_info
begin
self.auth_info = SecureRandom.hex
end while self.class.exists?(auth_info: auth_info)
end
# rubocop:enable Lint/Loop
def attach_default_contacts
tech_contacts << owner_contact if tech_contacts_count.zero?

View file

@ -29,9 +29,26 @@ class DomainStatus < ActiveRecord::Base
DELETE_CANDIDATE = 'deleteCandidate'
EXPIRED = 'expired'
STATUSES = [CLIENT_DELETE_PROHIBITED, SERVER_DELETE_PROHIBITED, CLIENT_HOLD, SERVER_HOLD, CLIENT_RENEW_PROHIBITED, SERVER_RENEW_PROHIBITED, CLIENT_TRANSFER_PROHIBITED, SERVER_TRANSFER_PROHIBITED, CLIENT_UPDATE_PROHIBITED, SERVER_UPDATE_PROHIBITED, INACTIVE, OK, PENDING_CREATE, PENDING_DELETE, PENDING_RENEW, PENDING_TRANSFER, PENDING_UPDATE, SERVER_MANUAL_INZONE, SERVER_REGISTRANT_CHANGE_PROHIBITED, SERVER_ADMIN_CHANGE_PROHIBITED, SERVER_TECH_CHANGE_PROHIBITED, FORCE_DELETE, DELETE_CANDIDATE, EXPIRED]
CLIENT_STATUSES = [CLIENT_DELETE_PROHIBITED, CLIENT_HOLD, CLIENT_RENEW_PROHIBITED, CLIENT_TRANSFER_PROHIBITED, CLIENT_UPDATE_PROHIBITED]
SERVER_STATUSES = [SERVER_DELETE_PROHIBITED, SERVER_HOLD, SERVER_RENEW_PROHIBITED, SERVER_TRANSFER_PROHIBITED, SERVER_UPDATE_PROHIBITED, SERVER_MANUAL_INZONE, SERVER_REGISTRANT_CHANGE_PROHIBITED, SERVER_ADMIN_CHANGE_PROHIBITED, SERVER_TECH_CHANGE_PROHIBITED]
STATUSES = [
CLIENT_DELETE_PROHIBITED, SERVER_DELETE_PROHIBITED, CLIENT_HOLD, SERVER_HOLD,
CLIENT_RENEW_PROHIBITED, SERVER_RENEW_PROHIBITED, CLIENT_TRANSFER_PROHIBITED,
SERVER_TRANSFER_PROHIBITED, CLIENT_UPDATE_PROHIBITED, SERVER_UPDATE_PROHIBITED,
INACTIVE, OK, PENDING_CREATE, PENDING_DELETE, PENDING_RENEW, PENDING_TRANSFER,
PENDING_UPDATE, SERVER_MANUAL_INZONE, SERVER_REGISTRANT_CHANGE_PROHIBITED,
SERVER_ADMIN_CHANGE_PROHIBITED, SERVER_TECH_CHANGE_PROHIBITED, FORCE_DELETE,
DELETE_CANDIDATE, EXPIRED
]
CLIENT_STATUSES = [
CLIENT_DELETE_PROHIBITED, CLIENT_HOLD, CLIENT_RENEW_PROHIBITED, CLIENT_TRANSFER_PROHIBITED,
CLIENT_UPDATE_PROHIBITED
]
SERVER_STATUSES = [
SERVER_DELETE_PROHIBITED, SERVER_HOLD, SERVER_RENEW_PROHIBITED, SERVER_TRANSFER_PROHIBITED,
SERVER_UPDATE_PROHIBITED, SERVER_MANUAL_INZONE, SERVER_REGISTRANT_CHANGE_PROHIBITED,
SERVER_ADMIN_CHANGE_PROHIBITED, SERVER_TECH_CHANGE_PROHIBITED
]
# archiving
has_paper_trail class_name: 'DomainStatusVersion'

View file

@ -1,3 +1,4 @@
# rubocop: disable Metrics/ClassLength
class Epp::EppDomain < Domain
include EppErrors
@ -24,10 +25,10 @@ class Epp::EppDomain < Domain
],
'2004' => [ # Parameter value range error
[:nameservers, :out_of_range,
{
min: domain_validation_sg.setting(:ns_min_count).value,
max: domain_validation_sg.setting(:ns_max_count).value
}
{
min: domain_validation_sg.setting(:ns_min_count).value,
max: domain_validation_sg.setting(:ns_max_count).value
}
],
[:period, :out_of_range, { value: { obj: 'period', val: period } }],
[:dnskeys, :out_of_range,
@ -81,8 +82,8 @@ class Epp::EppDomain < Domain
# TODO: Find out if there are any attributes that can be changed
# if not, delete this method
def parse_and_update_domain_attributes(parsed_frame)
#assign_attributes(self.class.parse_update_params_from_frame(parsed_frame))
def parse_and_update_domain_attributes(_parsed_frame)
# assign_attributes(self.class.parse_update_params_from_frame(parsed_frame))
errors.empty?
end
@ -276,6 +277,9 @@ class Epp::EppDomain < Domain
### TRANSFER ###
# rubocop: disable Metrics/PerceivedComplexity
# rubocop: disable Metrics/MethodLength
# rubocop: disable Metrics/CyclomaticComplexity
def transfer(params)
return false unless authenticate(params[:pw])
@ -314,6 +318,9 @@ class Epp::EppDomain < Domain
save
end
end
# rubocop: enable Metrics/PerceivedComplexity
# rubocop: enable Metrics/MethodLength
# rubocop: enable Metrics/CyclomaticComplexity
def approve_pending_transfer(current_user)
pt = pending_transfer
@ -479,3 +486,4 @@ class Epp::EppDomain < Domain
end
end
end
# rubocop: enable Metrics/ClassLength

View file

@ -2,7 +2,7 @@ class EppSession < ActiveRecord::Base
before_save :marshal_data!
def data
@data ||= self.class.unmarshal(read_attribute(:data)) || {}
@data ||= self.class.unmarshal(self[:data]) || {}
end
def [](key)

View file

@ -1,5 +1,6 @@
# rubocop: disable Metrics/ClassLength
class EppUser < ActiveRecord::Base
# TODO should have max request limit per day
# TODO: should have max request limit per day
belongs_to :registrar
has_many :contacts
@ -16,3 +17,4 @@ class EppUser < ActiveRecord::Base
username
end
end
# rubocop: enable Metrics/ClassLength

View file

@ -4,9 +4,11 @@ class Nameserver < ActiveRecord::Base
belongs_to :registrar
belongs_to :domain
# rubocop: disable Metrics/LineLength
validates :hostname, format: { with: /\A(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])\z/ }
validates :ipv4, format: { with: /\A(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\z/, allow_blank: true }
validates :ipv6, format: { with: /(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/, allow_blank: true }
# rubocop: enable Metrics/LineLength

View file

@ -1,14 +1,13 @@
class Registrar < ActiveRecord::Base
belongs_to :country
has_many :domains, :dependent => :restrict_with_error
has_many :contacts, :dependent => :restrict_with_error
has_many :epp_users, :dependent => :restrict_with_error
has_many :users, :dependent => :restrict_with_error
has_many :domains, dependent: :restrict_with_error
has_many :contacts, dependent: :restrict_with_error
has_many :epp_users, dependent: :restrict_with_error
has_many :users, dependent: :restrict_with_error
validates :name, :reg_no, :address, :country, presence: true
validates :name, :reg_no, uniqueness: true
def domain_transfers
at = DomainTransfer.arel_table
DomainTransfer.where(

View file

@ -1,3 +1,5 @@
class Right < ActiveRecord::Base
# rubocop: disable Rails/HasAndBelongsToMany
has_and_belongs_to_many :roles
# rubocop: enable Rails/HasAndBelongsToMany
end

View file

@ -1,4 +1,6 @@
class Role < ActiveRecord::Base
has_many :users
# rubocop: disable Rails/HasAndBelongsToMany
has_and_belongs_to_many :rights
# rubocop: enbale Rails/HasAndBelongsToMany
end

View file

@ -2,9 +2,9 @@ class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :trackable, :timeoutable
# TODO Foreign user will get email with activation link,email,temp-password.
# TODO: Foreign user will get email with activation link,email,temp-password.
# After activisation, system should require to change temp password.
# TODO Estonian id validation
# TODO: Estonian id validation
belongs_to :role
belongs_to :registrar

View file

@ -28,10 +28,14 @@ class DomainNameValidator < ActiveModel::EachValidator
value = SimpleIDN.to_unicode(value).mb_chars.downcase.strip
end
# rubocop: disable Metrics/LineLength
unicode_chars = /\u00E4\u00F5\u00F6\u00FC\u0161\u017E/ # äõöüšž
regexp = /\A[a-zA-Z0-9#{unicode_chars}][a-zA-Z0-9#{unicode_chars}-]{0,61}[a-zA-Z0-9#{unicode_chars}]#{general_domains}\z/
# rubocop: enable Metrics/LineLength
# rubocop: disable Style/DoubleNegation
!!(value =~ regexp)
# rubocop: enable Style/DoubleNegation
end
def validate_reservation(value)

View file

@ -9,7 +9,11 @@
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
= javascript_include_tag 'application', 'data-turbolinks-track' => true
%link{href: "../../favicon.ico", rel: "icon"}/
%title= t('shared.eedirekt')
%title
- if can? :view, :registrar
= t(:registrar)
- else
= t('shared.eedirekt')
%body
/ Static navbar
.navbar.navbar-default.navbar-static-top{role: "navigation"}
@ -20,7 +24,11 @@
%span.icon-bar
%span.icon-bar
%span.icon-bar
= link_to t('shared.eedirekt'), client_domains_path, class: 'navbar-brand'
- if can? :view, :registrar
= link_to t(:registrar), client_domains_path, class: 'navbar-brand'
- else
= link_to t('shared.eedirekt'), client_domains_path, class: 'navbar-brand'
.navbar-collapse.collapse
%ul.nav.navbar-nav
- active_class = ['client/domains', 'client/domain_transfers'].include?(params[:controller]) ? 'active' :nil