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

This commit is contained in:
Martin Lensment 2014-08-05 16:08:38 +03:00
commit 356835bebf
7 changed files with 66 additions and 6 deletions

View file

@ -46,21 +46,33 @@ module Epp::ContactsHelper
end
def info_contact
#TODO do we reject contact without authInfo or display less info?
#TODO add data missing from contacts/info builder ( marked with 'if false' in said view )
current_epp_user
ph = params_hash['epp']['command']['info']['info']
@contact = Contact.where(code: ph[:id]).first
if @contact
case has_rights
when true
render '/epp/contacts/info'
else
epp_errors << { code: '2303', msg: t('errors.messages.epp_obj_does_not_exist') }
when false
epp_errors << { code: '2201', msg: t('errors.messages.epp_authorization_error') }
render 'epp/error'
end
rescue NoMethodError => e
epp_errors << { code: '2303', msg: t('errors.messages.epp_obj_does_not_exist') }
render 'epp/error'
end
private
def has_rights
if @contact.created_by.registrar == current_epp_user.registrar
return true
end
return false
end
def new_address
ph = params_hash['epp']['command']['create']['create']

View file

@ -6,6 +6,9 @@ class Contact < ActiveRecord::Base
has_many :domain_contacts
has_many :domains, through: :domain_contacts
belongs_to :created_by, class_name: 'EppUser', foreign_key: :created_by_id
belongs_to :updated_by, class_name: 'EppUser', foreign_key: :updated_by_id
validates_presence_of :code, :name, :phone, :email, :ident
validate :ident_must_be_valid
@ -39,6 +42,14 @@ class Contact < ActiveRecord::Base
ident_type != IDENT_TYPE_ICO
end
def crID
created_by ? created_by.username : nil
end
def upID
updated_by ? updated_by.username : nil
end
class << self
def check_availability(codes)
codes = [codes] if codes.is_a?(String)

View file

@ -1,4 +1,5 @@
class EppUser < ActiveRecord::Base
#TODO should have max request limit per day
belongs_to :registrar
has_many :contacts
end

View file

@ -17,9 +17,9 @@ xml.epp_head do
xml.tag!('contact:fax', @contact.fax)
xml.tag!('contact:email', @contact.email)
xml.tag!('contact:clID', @current_epp_user.username) if @current_epp_user
xml.tag!('contact:crID', '123') if false
xml.tag!('contact:crID', @contact.crID ) if @contact.crID
xml.tag!('contact:crDate', @contact.created_at)
xml.tag!('contact:upID', '123') if false
xml.tag!('contact:upID', @contact.upID) if @contact.upID
xml.tag!('contact:upDate', @contact.updated_at) unless @contact.updated_at == @contact.created_at
xml.tag!('contact:trDate', '123') if false
xml.tag!('contact:authInfo', '123') if false