diff --git a/app/controllers/admin/pending_deletes_controller.rb b/app/controllers/admin/pending_deletes_controller.rb index a64a34714..2eda703bd 100644 --- a/app/controllers/admin/pending_deletes_controller.rb +++ b/app/controllers/admin/pending_deletes_controller.rb @@ -5,9 +5,7 @@ class Admin::PendingDeletesController < AdminController def update authorize! :update, :pending - @epp_domain = Epp::Domain.find(params[:domain_id]) # only epp domain has apply pending - @epp_domain.is_admin= true - if @epp_domain.apply_pending_delete! + if registrant_verification.domain_registrant_delete_confirm! redirect_to admin_domain_path(@domain.id), notice: t(:pending_applied) else redirect_to admin_edit_domain_path(@domain.id), alert: t(:failure) @@ -17,7 +15,7 @@ class Admin::PendingDeletesController < AdminController def destroy authorize! :destroy, :pending - if @domain.clean_pendings! + if registrant_verification.domain_registrant_delete_reject! redirect_to admin_domain_path(@domain.id), notice: t(:pending_removed) else redirect_to admin_domain_path(@domain.id), alert: t(:failure) @@ -26,6 +24,14 @@ class Admin::PendingDeletesController < AdminController private + def registrant_verification + # steal token + token = @domain.registrant_verification_token + @registrant_verification = RegistrantVerification.new(domain_id: @domain.id, + domain_name: @domain.name, + verification_token: token) + end + def find_domain @domain = Domain.find(params[:domain_id]) end diff --git a/app/controllers/admin/pending_updates_controller.rb b/app/controllers/admin/pending_updates_controller.rb index 4d08297d7..6e41a6c57 100644 --- a/app/controllers/admin/pending_updates_controller.rb +++ b/app/controllers/admin/pending_updates_controller.rb @@ -5,8 +5,7 @@ class Admin::PendingUpdatesController < AdminController def update authorize! :update, :pending - @epp_domain = Epp::Domain.find(params[:domain_id]) # only epp domain has apply pending - if @epp_domain.apply_pending_update! + if registrant_verification.domain_registrant_change_confirm! redirect_to admin_domain_path(@domain.id), notice: t(:pending_applied) else redirect_to edit_admin_domain_path(@domain.id), alert: t(:failure) @@ -15,14 +14,21 @@ class Admin::PendingUpdatesController < AdminController def destroy authorize! :destroy, :pending - - if @domain.clean_pendings! + if registrant_verification.domain_registrant_change_reject! redirect_to admin_domain_path(@domain.id), notice: t(:pending_removed) else redirect_to admin_domain_path(@domain.id), alert: t(:failure) end end + def registrant_verification + # steal token + token = @domain.registrant_verification_token + @registrant_verification = RegistrantVerification.new(domain_id: @domain.id, + domain_name: @domain.name, + verification_token: token) + end + private def find_domain diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 318923e3d..5d051377d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -67,8 +67,7 @@ class ApplicationController < ActionController::Base end def user_log_str(user) - return 'public' if user.nil? - "#{user.id}-#{user.class}: #{user.username}" + user.nil? ? 'public' : user.id_role_username end def comma_support_for(parent_key, key) diff --git a/app/controllers/epp/domains_controller.rb b/app/controllers/epp/domains_controller.rb index f8cb2b752..91ddeb93d 100644 --- a/app/controllers/epp/domains_controller.rb +++ b/app/controllers/epp/domains_controller.rb @@ -29,11 +29,6 @@ class Epp::DomainsController < EppController handle_errors(@domain) and return if @domain.errors.any? handle_errors and return unless balance_ok?('create') # loads pricelist in this method - if !@domain_pricelist.try(:price)#checking if pricelist is not found - @domain.add_epp_error('2306', nil, nil, 'No price list for domain') - handle_errors(@domain) and return if @domain.errors.any? - end - ActiveRecord::Base.transaction do if @domain.save # TODO: Maybe use validate: false here because we have already validated the domain? current_user.registrar.debit!({ @@ -107,10 +102,6 @@ class Epp::DomainsController < EppController period_unit = Epp::Domain.parse_period_unit_from_frame(params[:parsed_frame]) || 'y' balance_ok?('renew', period, period_unit) # loading pricelist - if !@domain_pricelist.try(:price)#checking if pricelist is not found - @domain.add_epp_error('2306', nil, nil, 'No price list for domain') - handle_errors(@domain) and return if @domain.errors.any? - end ActiveRecord::Base.transaction do success = @domain.renew( @@ -258,12 +249,19 @@ class Epp::DomainsController < EppController def balance_ok?(operation, period = nil, unit = nil) @domain_pricelist = @domain.pricelist(operation, period.try(:to_i), unit) - if current_user.registrar.balance < @domain_pricelist.price.amount + if @domain_pricelist.try(:price) # checking if price list is not found + if current_user.registrar.balance < @domain_pricelist.price.amount + epp_errors << { + code: '2104', + msg: I18n.t('billing_failure_credit_balance_low') + } + return false + end + else epp_errors << { - code: '2104', - msg: I18n.t('billing_failure_credit_balance_low') + code: '2104', + msg: I18n.t(:active_price_missing_for_this_operation) } - return false end true diff --git a/app/controllers/registrar/contacts_controller.rb b/app/controllers/registrar/contacts_controller.rb index f4ce84d8c..878e29cd2 100644 --- a/app/controllers/registrar/contacts_controller.rb +++ b/app/controllers/registrar/contacts_controller.rb @@ -3,18 +3,61 @@ class Registrar::ContactsController < Registrar::DeppController # EPP controller def index authorize! :view, Depp::Contact - limit, offset = pagination_details - res = depp_current_user.repp_request('contacts', { details: true, limit: limit, offset: offset }) - if res.code == '200' - @response = res.parsed_body.with_indifferent_access - @contacts = @response ? @response[:contacts] : [] - - @paginatable_array = Kaminari.paginate_array( - [], total_count: @response[:total_number_of_records] - ).page(params[:page]).per(limit) + params[:q] ||= {} + params[:q].delete_if { |_k, v| v.blank? } + if params[:q].length == 1 && params[:q][:name_matches].present? + @contacts = Contact.find_by(name: params[:q][:name_matches]) end - flash.now[:epp_results] = [{ 'code' => res.code, 'msg' => res.message }] + + if params[:statuses_contains] + contacts = current_user.registrar.contacts.includes(:registrar).where( + "contacts.statuses @> ?::varchar[]", "{#{params[:statuses_contains].join(',')}}" + ) + else + contacts = current_user.registrar.contacts.includes(:registrar) + end + + normalize_search_parameters do + @q = contacts.search(params[:q]) + @contacts = @q.result.page(params[:page]) + end + + @contacts = @contacts.per(params[:results_per_page]) if params[:results_per_page].to_i > 0 + end + + def download_list + authorize! :view, Depp::Contact + + params[:q] ||= {} + params[:q].delete_if { |_k, v| v.blank? } + if params[:q].length == 1 && params[:q][:name_matches].present? + @contacts = Contact.find_by(name: params[:q][:name_matches]) + end + + if params[:statuses_contains] + contacts = current_user.registrar.contacts.includes(:registrar).where( + "contacts.statuses @> ?::varchar[]", "{#{params[:statuses_contains].join(',')}}" + ) + else + contacts = current_user.registrar.contacts.includes(:registrar) + end + + normalize_search_parameters do + @q = contacts.search(params[:q]) + @contacts = @q.result.page(params[:page]) + end + + @contacts = @contacts.per(params[:results_per_page]) if params[:results_per_page].to_i > 0 + + respond_to do |format| + format.csv { render text: @contacts.to_csv } + format.pdf do + pdf = @contacts.pdf(render_to_string('registrar/contacts/download_list', layout: false)) + send_data pdf, filename: 'contacts.pdf' + end + end + end def new @@ -75,4 +118,18 @@ class Registrar::ContactsController < Registrar::DeppController # EPP controller def init_epp_contact Depp::Contact.user = depp_current_user end + + def normalize_search_parameters + ca_cache = params[:q][:valid_to_lteq] + begin + end_time = params[:q][:valid_to_lteq].try(:to_date) + params[:q][:valid_to_lteq] = end_time.try(:end_of_day) + rescue + logger.warn('Invalid date') + end + + yield + + params[:q][:valid_to_lteq] = ca_cache + end end diff --git a/app/jobs/domain_update_confirm_job.rb b/app/jobs/domain_update_confirm_job.rb index 28294ef25..be0ada219 100644 --- a/app/jobs/domain_update_confirm_job.rb +++ b/app/jobs/domain_update_confirm_job.rb @@ -10,8 +10,9 @@ class DomainUpdateConfirmJob < Que::Job e.instance_variable_set("@changed_attributes", e.changed_attributes.merge("statuses"=>[])) end domain.clean_pendings! + WhoisRecord.find_by(domain_id: domain.id).save when RegistrantVerification::REJECTED - DomainMailer.pending_update_rejected_notification_for_new_registrant(domain_id).deliver + domain.send_mail :pending_update_rejected_notification_for_new_registrant domain.poll_message!(:poll_pending_update_rejected_by_registrant) domain.clean_pendings! domain.instance_variable_set("@changed_attributes", domain.changed_attributes.merge("statuses"=>[])) diff --git a/app/mailers/domain_mailer.rb b/app/mailers/domain_mailer.rb index 3788dd510..66533e316 100644 --- a/app/mailers/domain_mailer.rb +++ b/app/mailers/domain_mailer.rb @@ -1,109 +1,28 @@ class DomainMailer < ApplicationMailer include Que::Mailer - def pending_update_request_for_old_registrant(domain_id, old_registrant_id, should_deliver) - @domain = Domain.find_by(id: domain_id) - @old_registrant = Registrant.find(old_registrant_id) - return unless @domain - return if delivery_off?(@domain, should_deliver) - - if @domain.registrant_verification_token.blank? - logger.warn "EMAIL NOT DELIVERED: registrant_verification_token is missing for #{@domain.name}" - return - end - - if @domain.registrant_verification_asked_at.blank? - logger.warn "EMAIL NOT DELIVERED: registrant_verification_asked_at is missing for #{@domain.name}" - return - end - - confirm_path = "#{ENV['registrant_url']}/registrant/domain_update_confirms" - @verification_url = "#{confirm_path}/#{@domain.id}?token=#{@domain.registrant_verification_token}" - - return if whitelist_blocked?(@old_registrant.email) - mail(to: format(@old_registrant.email), - subject: "#{I18n.t(:pending_update_request_for_old_registrant_subject, - name: @domain.name)} [#{@domain.name}]") + def pending_update_request_for_old_registrant(params) + compose_from(params) end - def pending_update_notification_for_new_registrant(domain_id, old_registrant_id, should_deliver) - @domain = Domain.find_by(id: domain_id) - @old_registrant = Registrant.find(old_registrant_id) - return unless @domain - return if delivery_off?(@domain, should_deliver) - - if @domain.registrant_verification_token.blank? - logger.warn "EMAIL NOT DELIVERED: registrant_verification_token is missing for #{@domain.name}" - return - end - - if @domain.registrant_verification_asked_at.blank? - logger.warn "EMAIL NOT DELIVERED: registrant_verification_asked_at is missing for #{@domain.name}" - return - end - - @new_registrant = @domain.registrant # NB! new registrant at this point - - return if whitelist_blocked?(@new_registrant.email) - mail(to: format(@new_registrant.email), - subject: "#{I18n.t(:pending_update_notification_for_new_registrant_subject, - name: @domain.name)} [#{@domain.name}]") + def pending_update_notification_for_new_registrant(params) + compose_from(params) end - def registrant_updated_notification_for_new_registrant(domain_id, should_deliver) - @domain = Domain.find_by(id: domain_id) - return unless @domain - return if delivery_off?(@domain, should_deliver) - - return if whitelist_blocked?(@domain.registrant_email) - mail(to: format(@domain.registrant_email), - subject: "#{I18n.t(:registrant_updated_notification_for_new_registrant_subject, - name: @domain.name)} [#{@domain.name}]") + def registrant_updated_notification_for_new_registrant(params) + compose_from(params) end - def registrant_updated_notification_for_old_registrant(domain_id, should_deliver) - domain = Domain.find_by(id: domain_id) - return unless domain - return if delivery_off?(@domain, should_deliver) - - @old_registrant_email = domain.registrant_email # Nb! before applying pending updates - - return if whitelist_blocked?(@old_registrant_email) - mail(to: format(@old_registrant_email), - subject: "#{I18n.t(:registrant_updated_notification_for_old_registrant_subject, - name: @domain.name)} [#{@domain.name}]") + def registrant_updated_notification_for_old_registrant(params) + compose_from(params) end - def pending_update_rejected_notification_for_new_registrant(domain_id) - @domain = Domain.find_by(id: domain_id) - return unless @domain - # no delivery off control, driggered by que, no epp request - - @new_registrant_email = @domain.pending_json['new_registrant_email'] - @new_registrant_name = @domain.pending_json['new_registrant_name'] - - return if whitelist_blocked?(@new_registrant_email) - mail(to: format(@new_registrant_email), - subject: "#{I18n.t(:pending_update_rejected_notification_for_new_registrant_subject, - name: @domain.name)} [#{@domain.name}]") + def pending_update_rejected_notification_for_new_registrant(params) + compose_from(params) end - def pending_update_expired_notification_for_new_registrant(domain_id) - @domain = Domain.find_by(id: domain_id) - return unless @domain - # no delivery off control, driggered by cron, no epp request - - @new_registrant_email = @domain.pending_json['new_registrant_email'] - @new_registrant_name = @domain.pending_json['new_registrant_name'] - - return if whitelist_blocked?(@new_registrant_email) - if @new_registrant_email.blank? - logger.info "EMAIL NOT DELIVERED: no registrant email [pending_update_expired_notification_for_new_registrant]" - return - end - mail(to: format(@new_registrant_email), - subject: "#{I18n.t(:pending_update_expired_notification_for_new_registrant_subject, - name: @domain.name)} [#{@domain.name}]") + def pending_update_expired_notification_for_new_registrant(params) + compose_from(params) end def pending_deleted(domain_id, old_registrant_id, should_deliver) @@ -197,4 +116,18 @@ class DomainMailer < ApplicationMailer subject: "#{I18n.t(:force_delete_subject)}" ) end + + private + # app/models/DomainMailModel provides the data for mail that can be composed_from + # which ensures that values of objects are captured when they are valid, not later when this method is executed + def compose_from(params) + @params = params + return if delivery_off?(params, params[:deliver_emails]) + return if whitelist_blocked?(params[:recipient]) + params[:errors].map do |error| + logger.warn error + return + end + mail(to: params[:recipient], subject: params[:subject]) + end end diff --git a/app/models/concerns/user_events.rb b/app/models/concerns/user_events.rb index 12ff18444..25a225e8b 100644 --- a/app/models/concerns/user_events.rb +++ b/app/models/concerns/user_events.rb @@ -1,23 +1,30 @@ module UserEvents extend ActiveSupport::Concern - # TODO: remove old - # module ClassMethods - # def registrar_events(id) - # registrar = Registrar.find(id) - # return [] unless registrar - # @events = [] - # registrar.users.each { |user| @events << user_events(user.id) } - # registrar.epp_users.each { |user| @events << epp_user_events(user.id) } - # @events - # end + included do + # EPP requires a server defined creator ID, which should be registrar code if we have one + def cr_id + # try this, rebuild user for registrar before searching history? really? + registrar = self.creator.try(:registrar) + if registrar.present? # Did creator return a kind of User that has a registrar? + registrar.code + else + if self.versions.first.try(:object).nil? + changes = self.versions.first.try(:object_changes) + cr_registrar_id = changes['registrar_id'].second if changes.present? + else + # untested, expected never to execute + cr_registrar_id = self.versions.first.object['registrar_id'] + end - # def user_events(id) - # where(whodunnit: id.to_s) - # end + if cr_registrar_id.present? + Registrar.find(cr_registrar_id).code + else + # cr_id optional for domain, but required for contact; but we want something here anyway + self.creator_str # Fallback if we failed, maybe we can find a string here + end + end + end + end - # def epp_user_events(id) - # where(whodunnit: "#{id}-EppUser") - # end - # end end diff --git a/app/models/concerns/versions.rb b/app/models/concerns/versions.rb index 2cbdca838..768cf021e 100644 --- a/app/models/concerns/versions.rb +++ b/app/models/concerns/versions.rb @@ -22,32 +22,30 @@ module Versions def creator return nil if creator_str.blank? - - if creator_str =~ /^\d+-AdminUser:/ - creator = AdminUser.find_by(id: creator_str) - elsif creator_str =~ /^\d+-ApiUser:/ - creator = ApiUser.find_by(id: creator_str) - elsif creator_str =~ /^\d+-api-/ # depricated - creator = ApiUser.find_by(id: creator_str) - end - + creator = user_from_id_role_username creator_str creator.present? ? creator : creator_str end def updator return nil if updator_str.blank? - - if updator_str =~ /^\d+-AdminUser:/ - updator = AdminUser.find_by(id: updator_str) - elsif updator_str =~ /^\d+-ApiUser:/ - updator = ApiUser.find_by(id: updator_str) - elsif updator_str =~ /^\d+-api-/ # depricated - updator = ApiUser.find_by(id: updator_str) - end - + updator = user_from_id_role_username updator_str updator.present? ? updator : updator_str end + def user_from_id_role_username(str) + user = ApiUser.find_by(id: $1) if str =~ /^(\d+)-(ApiUser:|api-)/ + unless user.present? + user = AdminUser.find_by(id: $1) if str =~ /^(\d+)-AdminUser:/ + unless user.present? + # on import we copied Registrar name, which may eql code + registrar = Registrar.find_by(name: str) + # assume each registrar has only one user + user = registrar.api_users.first if registrar + end + end + user + end + # callbacks def touch_domain_version domain.try(:touch_with_version) diff --git a/app/models/contact.rb b/app/models/contact.rb index 1d6f069e5..d68caacc5 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -1,6 +1,7 @@ class Contact < ActiveRecord::Base include Versions # version/contact_version.rb include EppErrors + include UserEvents belongs_to :registrar has_many :domain_contacts @@ -57,6 +58,11 @@ class Contact < ActiveRecord::Base before_save :manage_statuses def manage_statuses + if domain_transfer # very ugly but need better workflow + self.statuses = statuses | [OK, LINKED] + return + end + manage_linked manage_ok end @@ -80,6 +86,7 @@ class Contact < ActiveRecord::Base ] attr_accessor :deliver_emails + attr_accessor :domain_transfer # hack but solves problem faster # # STATUSES @@ -203,6 +210,21 @@ class Contact < ActiveRecord::Base ['DeleteProhibited', SERVER_DELETE_PROHIBITED] ] end + + def to_csv + CSV.generate do |csv| + csv << column_names + all.each do |contact| + csv << contact.attributes.values_at(*column_names) + end + end + end + + def pdf(html) + kit = PDFKit.new(html) + kit.to_pdf + end + end def roid @@ -472,7 +494,7 @@ class Contact < ActiveRecord::Base end def update_related_whois_records - related_domain_descriptions.each{ |x, y| WhoisRecord.find_by(name: x).save} + related_domain_descriptions.each{ |x, y| WhoisRecord.find_by(name: x).try(:save) } end end diff --git a/app/models/depp/domain.rb b/app/models/depp/domain.rb index fd0e71e9b..7b4630008 100644 --- a/app/models/depp/domain.rb +++ b/app/models/depp/domain.rb @@ -152,23 +152,17 @@ module Depp } end - data.css('dsData').each_with_index do |x, i| - ds = { - ds_key_tag: x.css('keyTag').first.try(:text), - ds_alg: x.css('alg').first.try(:text), - ds_digest_type: x.css('digestType').first.try(:text), - ds_digest: x.css('digest').first.try(:text) + data.css('keyData').each_with_index do |x, i| + ret[:dnskeys_attributes][i] = { + flags: x.css('flags').text, + protocol: x.css('protocol').text, + alg: x.css('alg').text, + public_key: x.css('pubKey').text, + ds_key_tag: x.css('keyTag').first.try(:text), + ds_alg: x.css('alg').first.try(:text), + ds_digest_type: x.css('digestType').first.try(:text), + ds_digest: x.css('digest').first.try(:text) } - - kd = x.css('keyData').first - ds.merge!({ - flags: kd.css('flags').first.try(:text), - protocol: kd.css('protocol').first.try(:text), - alg: kd.css('alg').first.try(:text), - public_key: kd.css('pubKey').first.try(:text) - }) if kd - - ret[:dnskeys_attributes][i] = ds end data.css('status').each_with_index do |x, i| diff --git a/app/models/domain.rb b/app/models/domain.rb index 53badd3fd..05ffafc4d 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -1,5 +1,6 @@ # rubocop: disable Metrics/ClassLength class Domain < ActiveRecord::Base + include UserEvents include Versions # version/domain_version.rb include Statuses has_paper_trail class_name: "DomainVersion", meta: { children: :children_log } @@ -238,10 +239,10 @@ class Domain < ActiveRecord::Base end count += 1 if domain.pending_update? - DomainMailer.pending_update_expired_notification_for_new_registrant(domain.id).deliver + domain.send_mail :pending_update_expired_notification_for_new_registrant end if domain.pending_delete? || domain.pending_delete_confirmation? - DomainMailer.pending_delete_expired_notification(domain.id, deliver_emails).deliver + DomainMailer.pending_delete_expired_notification(domain.id, true).deliver end domain.clean_pendings! unless Rails.env.test? @@ -307,7 +308,7 @@ class Domain < ActiveRecord::Base c = 0 Domain.where("statuses @> '{deleteCandidate}'::varchar[]").each do |x| - Whois::Record.where('domain_id = ?', x.id).try(':destroy') + WhoisRecord.where(domain_id: x.id).destroy_all destroy_with_message x STDOUT << "#{Time.zone.now.utc} Domain.destroy_delete_candidates: by deleteCandidate ##{x.id} (#{x.name})\n" unless Rails.env.test? @@ -315,7 +316,7 @@ class Domain < ActiveRecord::Base end Domain.where('force_delete_at <= ?', Time.zone.now).each do |x| - Whois::Record.where('domain_id = ?', x.id).try(':destroy') + WhoisRecord.where(domain_id: x.id).destroy_all destroy_with_message x STDOUT << "#{Time.zone.now.utc} Domain.destroy_delete_candidates: by force delete time ##{x.id} (#{x.name})\n" unless Rails.env.test? c += 1 @@ -439,7 +440,6 @@ class Domain < ActiveRecord::Base end def pending_update! - old_registrant_id = registrant_id_was return true if pending_update? self.epp_pending_update = true # for epp @@ -451,8 +451,8 @@ class Domain < ActiveRecord::Base new_registrant_email = registrant.email new_registrant_name = registrant.name - DomainMailer.pending_update_request_for_old_registrant(id, old_registrant_id, deliver_emails).deliver - DomainMailer.pending_update_notification_for_new_registrant(id, old_registrant_id, deliver_emails).deliver + send_mail :pending_update_request_for_old_registrant + send_mail :pending_update_notification_for_new_registrant reload # revert back to original @@ -818,5 +818,10 @@ class Domain < ActiveRecord::Base status_notes[status] = notes[i] end end + + def send_mail(action) + DomainMailer.send(action, DomainMailModel.new(self).send(action)).deliver + end + end # rubocop: enable Metrics/ClassLength diff --git a/app/models/domain_mail_model.rb b/app/models/domain_mail_model.rb new file mode 100644 index 000000000..46309ad52 --- /dev/null +++ b/app/models/domain_mail_model.rb @@ -0,0 +1,180 @@ +class DomainMailModel + # Capture current values used in app/views/mailers/domain_mailer/* and app/mailers/domain_mailer will send later + + def initialize(domain) + @domain = domain + @params = {errors: [], deliver_emails: domain.deliver_emails, id: domain.id} + end + + def pending_update_request_for_old_registrant + registrant_old + subject(:pending_update_request_for_old_registrant_subject) + confirm_update + domain_info + compose + end + + def pending_update_notification_for_new_registrant + registrant # new registrant at this point + subject(:pending_update_notification_for_new_registrant_subject) + domain_info + compose + end + + def registrant_updated_notification_for_new_registrant + registrant + subject(:registrant_updated_notification_for_new_registrant_subject) + domain_info + compose + end + + def registrant_updated_notification_for_old_registrant + registrant_pending + registrant_old + subject(:registrant_updated_notification_for_old_registrant_subject) + new_registrant = Registrant.find @domain.pending_json['new_registrant_id'] + @params[:registrant_name] = new_registrant.name + @params[:registrant_ident] = new_registrant.ident + @params[:registrant_priv] = new_registrant.priv? + @params[:registrant_email] = new_registrant.email + @params[:registrant_street] = new_registrant.street + @params[:registrant_city] = new_registrant.city + @params[:registrant_country] = new_registrant.country.name + compose + end + + def pending_update_rejected_notification_for_new_registrant + registrant_pending + subject(:pending_update_rejected_notification_for_new_registrant_subject) + @params[:deliver_emails] = true # triggered from que + @params[:registrar_name] = @domain.registrar.name + compose + end + + def pending_update_expired_notification_for_new_registrant + registrant_pending + subject(:pending_update_expired_notification_for_new_registrant_subject) + domain_info + compose + end + + def pending_deleted + registrant + subject(:domain_pending_deleted_subject) + confirm_delete + compose + end + + def pending_delete_rejected_notification + registrant + subject(:pending_delete_rejected_notification_subject) + compose + end + + def pending_delete_expired_notification + registrant + subject(:pending_delete_expired_notification_subject) + compose + end + + def delete_confirmation + registrant + subject(:delete_confirmation_subject) + compose + end + + def force_delete + admins + subject(:force_delete_subject) + compose + end + + private + + def registrant_old + @params[:recipient] = format Registrant.find(@domain.registrant_id_was).email + end + + def registrant + @params[:recipient] = format @domain.registrant.email + end + + def registrant_pending + @params[:recipient] = format @domain.pending_json['new_registrant_email'] + @params[:new_registrant_name] = @domain.pending_json['new_registrant_name'] + @params[:old_registrant_name] = @domain.registrant.name + end + + # registrant and domain admin contacts + def admins + emails = ([@domain.registrant.email] + @domain.admin_contacts.map { |x| format(x.email) }) + @params[:recipient] = emails.uniq.map { |x| format(x) } + end + + # puny internet domain name, TODO: username + def format(email) + return warn_no_email if email.nil? + user, host = email.split('@') + host = SimpleIDN.to_ascii(host) + "#{user}@#{host}" + end + + def subject(subject) + @params[:name] = @domain.name + @params[:subject] = "#{I18n.t(subject, name: @domain.name)}, [#{@domain.name}]" + end + + def confirm_update + verification_url('domain_update_confirms') + end + + def confirm_delete + verification_url('domain_delete_confirms') + end + + def compose + @params + end + + def verification_url(path) + token = verification_token or return + @params[:verification_url] = "#{ENV['registrant_url']}/registrant/#{path}/#{@domain.id}?token=#{token}" + end + + def verification_token + return warn_missing(:registrant_verification_token) if @domain.registrant_verification_token.blank? + return warn_missing(:registrant_verification_asked_at) if @domain.registrant_verification_asked_at.blank? + @domain.registrant_verification_token + end + + def domain_info + [:name, :registrar_name, + :registrant_name, :registrant_ident, :registrant_email, + :registrant_street,:registrant_city + ].each do |attr| + @params.store attr, @domain.send(attr) + end + @params.store :registrant_country, @domain.registrant_country.name + @params.store :registrant_priv, @domain.registrant.priv? + @params.store :old_registrant_name, Registrant.find(@domain.registrant_id_was).name + @params + end + + def warn_no_email(item = 'email') + warn_missing item + nil + end + + def warn_missing(item) + warn_not_delivered "#{item.to_s} is missing for #{@domain.name}" + end + + def warn_not_delivered(reason) + message = "EMAIL NOT DELIVERED: #{reason}" + @params[:errors] << message +# Rails.logger.warn message + nil + end + +end + diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 739c55bec..d84de4ca6 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -3,10 +3,12 @@ class Epp::Domain < Domain include EppErrors # TODO: remove this spagetti once data in production is correct. - attr_accessor :is_renewal + attr_accessor :is_renewal, :is_transfer before_validation :manage_permissions def manage_permissions + return if is_admin # this bad hack for 109086524, refactor later + return true if is_transfer return unless update_prohibited? || delete_prohibited? add_epp_error('2304', nil, nil, I18n.t(:object_status_prohibits_operation)) false @@ -14,7 +16,7 @@ class Epp::Domain < Domain after_validation :validate_contacts def validate_contacts - return true if is_renewal + return true if is_renewal || is_transfer ok = true active_admins = admin_domain_contacts.select { |x| !x.marked_for_destruction? } @@ -500,18 +502,23 @@ class Epp::Domain < Domain # rubocop: enable Metrics/CyclomaticComplexity def apply_pending_update! - old_registrant_email = DomainMailer.registrant_updated_notification_for_old_registrant(id, deliver_emails) preclean_pendings user = ApiUser.find(pending_json['current_user_id']) frame = Nokogiri::XML(pending_json['frame']) + + self.deliver_emails = true # turn on email delivery + send_mail :registrant_updated_notification_for_old_registrant + statuses.delete(DomainStatus::PENDING_UPDATE) yield(self) if block_given? # need to skip statuses check here + self.save + ::PaperTrail.whodunnit = user.id_role_username # updator str should be the request originator not the approval user return unless update(frame, user, false) clean_pendings! - self.deliver_emails = true # turn on email delivery - DomainMailer.registrant_updated_notification_for_new_registrant(id, deliver_emails).deliver - old_registrant_email.deliver + + send_mail :registrant_updated_notification_for_new_registrant + update_whois_record true end @@ -592,6 +599,8 @@ class Epp::Domain < Domain # rubocop: disable Metrics/CyclomaticComplexity def transfer(frame, action, current_user) + @is_transfer = true + case action when 'query' return domain_transfers.last if domain_transfers.any? @@ -619,6 +628,7 @@ class Epp::Domain < Domain oc.registrar_id = registrar_id oc.copy_from_id = c.id oc.prefix_code + oc.domain_transfer = true oc.save!(validate: false) oc end diff --git a/app/models/invoice.rb b/app/models/invoice.rb index 8bc5137d5..2f54e2287 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -17,7 +17,8 @@ class Invoice < ActiveRecord::Base validates :invoice_type, :due_date, :currency, :seller_name, :seller_iban, :buyer_name, :invoice_items, :vat_prc, presence: true - before_create :set_invoice_number + before_create :set_invoice_number, :check_vat + def set_invoice_number last_no = Invoice.order(number: :desc).where('number IS NOT NULL').limit(1).pluck(:number).first @@ -34,6 +35,12 @@ class Invoice < ActiveRecord::Base false end + def check_vat + if buyer.country_code != 'EE' && buyer.vat_no.present? + self.vat_prc = 0 + end + end + before_save -> { self.sum_cache = sum } class << self diff --git a/app/models/pricelist.rb b/app/models/pricelist.rb index 42cca0126..17420dfa1 100644 --- a/app/models/pricelist.rb +++ b/app/models/pricelist.rb @@ -31,7 +31,7 @@ class Pricelist < ActiveRecord::Base def pricelist_for(zone, operation, period) lists = valid.where(category: zone, operation_category: operation, duration: period) return lists.first if lists.count == 1 - lists.where('valid_to IS NOT NULL').order(valid_from: :desc).first + lists.order(valid_from: :desc).first end end end diff --git a/app/models/registrant_verification.rb b/app/models/registrant_verification.rb index 29bde4b70..253bac630 100644 --- a/app/models/registrant_verification.rb +++ b/app/models/registrant_verification.rb @@ -12,7 +12,6 @@ class RegistrantVerification < ActiveRecord::Base belongs_to :domain validates :verification_token, :domain_name, :domain, :action, :action_type, presence: true - validates :domain, uniqueness: { scope: [:domain_id, :verification_token] } def domain_registrant_change_confirm! self.action_type = DOMAIN_REGISTRANT_CHANGE diff --git a/app/models/user.rb b/app/models/user.rb index 0beb174f3..b69e0250c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -3,4 +3,9 @@ class User < ActiveRecord::Base devise :trackable, :timeoutable attr_accessor :phone + + def id_role_username + "#{self.id}-#{self.class}: #{self.username}" + end + end diff --git a/app/models/version/contact_version.rb b/app/models/version/contact_version.rb index 987dbc1fd..781813302 100644 --- a/app/models/version/contact_version.rb +++ b/app/models/version/contact_version.rb @@ -2,8 +2,6 @@ class ContactVersion < PaperTrail::Version include VersionSession self.table_name = :log_contacts self.sequence_name = :log_contacts_id_seq - - # include UserEvents - + # scope :deleted, -> { where(event: 'destroy') } end diff --git a/app/models/version/domain_version.rb b/app/models/version/domain_version.rb index 5bc25f1e1..2986d7811 100644 --- a/app/models/version/domain_version.rb +++ b/app/models/version/domain_version.rb @@ -4,7 +4,5 @@ class DomainVersion < PaperTrail::Version self.table_name = :log_domains self.sequence_name = :log_domains_id_seq - include UserEvents - scope :deleted, -> { where(event: 'destroy') } end diff --git a/app/models/whois_record.rb b/app/models/whois_record.rb index 21db2bdc0..528f84816 100644 --- a/app/models/whois_record.rb +++ b/app/models/whois_record.rb @@ -23,6 +23,10 @@ class WhoisRecord < ActiveRecord::Base end end + def self.find_by_name(name) + WhoisRecord.where("lower(name) = ?", name.downcase) + end + def generated_json @generated_json ||= generate_json end @@ -44,7 +48,7 @@ class WhoisRecord < ActiveRecord::Base h[:changed] = domain.updated_at.try(:to_s, :iso8601) h[:expire] = domain.valid_to.try(:to_date).try(:to_s) h[:outzone] = domain.outzone_at.try(:to_date).try(:to_s) - h[:delete] = domain.delete_at.try(:to_date).try(:to_s) + h[:delete] = [domain.delete_at, domain.force_delete_at].compact.min.try(:to_date).try(:to_s) h[:registrant] = domain.registrant.name @@ -113,6 +117,6 @@ class WhoisRecord < ActiveRecord::Base end def destroy_whois_record - Whois::Record.where(name: name).delete_all() + Whois::Record.where(name: name).delete_all end end diff --git a/app/views/admin/contacts/partials/_general.haml b/app/views/admin/contacts/partials/_general.haml index 194c5feb5..64f17612e 100644 --- a/app/views/admin/contacts/partials/_general.haml +++ b/app/views/admin/contacts/partials/_general.haml @@ -6,7 +6,7 @@ %dt= t(:id) %dd= @contact.code - %dt= t(:password) + %dt= t(:authinfo_pw) %dd = text_field_tag :auth_info, @contact.auth_info, readonly: true, class: 'partially-hidden' diff --git a/app/views/admin/domains/partials/_general.haml b/app/views/admin/domains/partials/_general.haml index d433a1302..d1a17c1cc 100644 --- a/app/views/admin/domains/partials/_general.haml +++ b/app/views/admin/domains/partials/_general.haml @@ -12,7 +12,7 @@ %dt= t(:registrar) %dd= link_to(@domain.registrar, admin_registrar_path(@domain.registrar)) - %dt= t(:password) + %dt= t(:authinfo_pw) %dd = text_field_tag :password, @domain.auth_info, readonly: true, class: 'partially-hidden' diff --git a/app/views/admin/keyrelays/show.haml b/app/views/admin/keyrelays/show.haml index 067cd4439..08f8b6f33 100644 --- a/app/views/admin/keyrelays/show.haml +++ b/app/views/admin/keyrelays/show.haml @@ -28,7 +28,7 @@ %dt= t(:public_key) %dd= @keyrelay.key_data_public_key - %dt= t(:password) + %dt= t(:authinfo_pw) %dd= @keyrelay.auth_info_pw %dt= t(:expiry_relative) diff --git a/app/views/epp/contacts/info.xml.builder b/app/views/epp/contacts/info.xml.builder index 18019208a..39aa91b39 100644 --- a/app/views/epp/contacts/info.xml.builder +++ b/app/views/epp/contacts/info.xml.builder @@ -46,15 +46,15 @@ xml.epp_head do xml.tag!('contact:email', 'No access') end - xml.tag!('contact:clID', @contact.registrar.try(:name)) - if @contact.creator.try(:registrar).blank? && Rails.env.test? - xml.tag!('contact:crID', 'TEST-CREATOR') - else - xml.tag!('contact:crID', @contact.creator.try(:registrar)) - end + xml.tag!('contact:clID', @contact.registrar.try(:code)) + + xml.tag!('contact:crID', @contact.cr_id) xml.tag!('contact:crDate', @contact.created_at.try(:iso8601)) + if @contact.updated_at != @contact.created_at - xml.tag!('contact:upID', @contact.updator.try(:registrar)) + upID = @contact.updator.try(:registrar) + upID = upID.code if upID.present? # Did updator return a kind of User that has a registrar? + xml.tag!('contact:upID', upID) if upID.present? # optional upID xml.tag!('contact:upDate', @contact.updated_at.try(:iso8601)) end # xml.tag!('contact:trDate', '123') if false diff --git a/app/views/epp/domains/info.xml.builder b/app/views/epp/domains/info.xml.builder index 9e1779921..ec5947b13 100644 --- a/app/views/epp/domains/info.xml.builder +++ b/app/views/epp/domains/info.xml.builder @@ -36,19 +36,20 @@ xml.epp_head do ## TODO Find out what this domain:host is all about - xml.tag!('domain:clID', @domain.registrar_name) - - xml.tag!('domain:crID', @domain.creator.try(:registrar)) if @domain.creator + xml.tag!('domain:clID', @domain.registrar.code) + xml.tag!('domain:crID', @domain.cr_id) xml.tag!('domain:crDate', @domain.created_at.try(:iso8601)) - xml.tag!('domain:upDate', @domain.updated_at.try(:iso8601)) if @domain.updated_at != @domain.created_at + if @domain.updated_at != @domain.created_at + upID = @domain.updator.try(:registrar) + upID = upID.code if upID.present? # Did updator return a kind of User that has a registrar? + xml.tag!('domain:upID', upID) if upID.present? # optional upID + xml.tag!('domain:upDate', @domain.updated_at.try(:iso8601)) + end xml.tag!('domain:exDate', @domain.valid_to.try(:iso8601)) - # TODO Make domain stampable - #xml.tag!('domain:upID', @domain.updated_by) - # TODO Make domain transferrable #xml.tag!('domain:trDate', @domain.transferred_at) if @domain.transferred_at diff --git a/app/views/mailers/domain_mailer/pending_update_expired_notification_for_new_registrant.html.erb b/app/views/mailers/domain_mailer/pending_update_expired_notification_for_new_registrant.html.erb index a8bf8723d..cfa539736 100644 --- a/app/views/mailers/domain_mailer/pending_update_expired_notification_for_new_registrant.html.erb +++ b/app/views/mailers/domain_mailer/pending_update_expired_notification_for_new_registrant.html.erb @@ -1,8 +1,8 @@ Tere,

-Domeeni <%= @domain.name %> registreerija <%= @domain.registrant_name %> ei kinnitanud tähtaegselt registreerija vahetuse taotlust. Domeeni <%= @domain.name %> registreerija vahetus on sellest tulenevalt tühistatud. +Domeeni <%= @params[:name] %> registreerija <%= @params[:registrant_name] %> ei kinnitanud tähtaegselt registreerija vahetuse taotlust. Domeeni <%= @params[:name] %> registreerija vahetus on sellest tulenevalt tühistatud.

-Küsimuste korral palun võtke ühendust registripidajaga <%= @domain.registrar_name %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad +Küsimuste korral palun võtke ühendust registripidajaga <%= @params[:registrar_name] %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad

Lugupidamisega
Eesti Interneti SA @@ -11,9 +11,9 @@ Eesti Interneti SA

Hi,

-Domain registrant change has been expired for the domain <%= @domain.name %>. +Domain registrant change has been expired for the domain <%= @params[:name] %>.

-Please contact to your registrar <%= @domain.registrar_name %> if you have any questions. +Please contact to your registrar <%= @params[:registrar_name] %> if you have any questions.

Best Regards,
Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/pending_update_expired_notification_for_new_registrant.text.erb b/app/views/mailers/domain_mailer/pending_update_expired_notification_for_new_registrant.text.erb index 020a9da65..626583562 100644 --- a/app/views/mailers/domain_mailer/pending_update_expired_notification_for_new_registrant.text.erb +++ b/app/views/mailers/domain_mailer/pending_update_expired_notification_for_new_registrant.text.erb @@ -1,8 +1,8 @@ Tere, -Domeeni <%= @domain.name %> registreerija <%= @domain.registrant_name %> ei kinnitanud tähtaegselt registreerija vahetuse taotlust. Domeeni <%= @domain.name %> registreerija vahetus on sellest tulenevalt tühistatud. +Domeeni <%= @params[:name] %> registreerija <%= @params[:registrant_name] %> ei kinnitanud tähtaegselt registreerija vahetuse taotlust. Domeeni <%= @params[:name] %> registreerija vahetus on sellest tulenevalt tühistatud. -Küsimuste korral palun võtke ühendust registripidajaga <%= @domain.registrar_name %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad +Küsimuste korral palun võtke ühendust registripidajaga <%= @params[:registrar_name] %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad Lugupidamisega Eesti Interneti SA @@ -11,9 +11,9 @@ Eesti Interneti SA Hi, -Domain registrant change has been expired for the domain <%= @domain.name %>. +Domain registrant change has been expired for the domain <%= @params[:name] %>. -Please contact to your registrar <%= @domain.registrar_name %> if you have any questions. +Please contact to your registrar <%= @params[:registrar_name] %> if you have any questions. Best Regards, Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.html.erb b/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.html.erb index df31c9139..07de23117 100644 --- a/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.html.erb +++ b/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.html.erb @@ -1,25 +1,25 @@ Tere,

-Registripidaja <%= @domain.registrar_name %> vahendusel on algatatud <%= @domain.name %> domeeni omanikuvahetuse protseduur. +Registripidaja <%= @params[:registrar_name] %> vahendusel on algatatud <%= @params[:name] %> domeeni omanikuvahetuse protseduur.

-Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @domain.registrar_name %> +Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @params[:registrar_name] %>

-Uued registreerija andmed:
-Nimi: <%= @domain.registrant_name %>
-<% if @domain.registrant.priv? %> - Isikukood: <%= @domain.registrant_ident %>
+Uue registreerija andmed:
+Nimi: <%= @params[:registrant_name] %>
+<% if @params[:registrant_priv] %> + Isikukood: <%= @params[:registrant_ident] %>
<% else %> - Äriregistrikood: <%= @domain.registrant_ident %>
+ Äriregistrikood: <%= @params[:registrant_ident] %>
<% end %> -Tänav: <%= @domain.registrant_street %>
-Linn: <%= @domain.registrant_city %>
-Riik: <%= @domain.registrant_country %> +Tänav: <%= @params[:registrant_street] %>
+Linn: <%= @params[:registrant_city] %>
+Riik: <%= @params[:registrant_country] %>

-Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiaks lõpule vaid juhul, kui domeeni hetkel kehtiv registreerija <%= @old_registrant.name %> omanikuvahetuse tähtaegselt kinnitab. +Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiaks lõpule vaid juhul, kui domeeni hetkel kehtiv registreerija <%= @params[:old_registrant_name] %> omanikuvahetuse tähtaegselt kinnitab.

-Juhul kui <%= @old_registrant.name %> lükkab omanikuvahtuse taotluse tagasi või ei anna kinnitust enne <%= Setting.expire_pending_confirmation %> tundi, omanikuvahetuse protseduur tühistatakse. +Juhul kui <%= @params[:old_registrant_name] %> lükkab omanikuvahtuse taotluse tagasi või ei anna kinnitust enne <%= Setting.expire_pending_confirmation %> tundi, omanikuvahetuse protseduur tühistatakse.

-Küsimuste korral palun võtke ühendust registripidajaga <%= @domain.registrar_name %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad +Küsimuste korral palun võtke ühendust registripidajaga <%= @params[:registrar_name] %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad

Lugupidamisega
Eesti Interneti SA @@ -28,20 +28,20 @@ Eesti Interneti SA

Hi,

-Registrant change process for the domain <%= @domain.name %> has been started. +Registrant change process for the domain <%= @params[:name] %> has been started.

New registrant:
-Name: <%= @domain.registrant_name %>
-<% if @domain.registrant.priv? %> -Personal code: <%= @domain.registrant_ident %>
+Name: <%= @params[:registrant_name] %>
+<% if @params[:registrant_priv] %> +Personal code: <%= @params[:registrant_ident] %>
<% else %> -Business Registry code: <%= @domain.registrant_ident %>
+Business Registry code: <%= @params[:registrant_ident] %>
<% end %> -Street: <%= @domain.registrant_street %>
-City: <%= @domain.registrant_city %>
-Country: <%= @domain.registrant_country %> +Street: <%= @params[:registrant_street] %>
+City: <%= @params[:registrant_city] %>
+Country: <%= @params[:registrant_country] %>

-Please contact to your registrar <%= @domain.registrar_name %> if you have any questions. +Please contact to your registrar <%= @params[:registrar_name] %> if you have any questions.

Best Regards,
Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.text.erb b/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.text.erb index 80265c05f..24005a58a 100644 --- a/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.text.erb +++ b/app/views/mailers/domain_mailer/pending_update_notification_for_new_registrant.text.erb @@ -1,25 +1,25 @@ Tere, -Registripidaja <%= @domain.registrar_name %> vahendusel on algatatud <%= @domain.name %> domeeni omanikuvahetuse protseduur. +Registripidaja <%= @params[:registrar_name] %> vahendusel on algatatud <%= @params[:name] %> domeeni omanikuvahetuse protseduur. -Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @domain.registrar_name %> +Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @params[:registrar_name] %> -Uued registreerija andmed: -Nimi: <%= @domain.registrant_name %> -<% if @domain.registrant.priv? %> -Isikukood: <%= @domain.registrant_ident %> +Uue registreerija andmed: +Nimi: <%= @params[:registrant_name] %> +<% if @params[:registrant_priv] %> +Isikukood: <%= @params[:registrant_ident] %> <% else %> -Äriregistrikood: <%= @domain.registrant_ident %> +Äriregistrikood: <%= @params[:registrant_ident] %> <% end %> -Tänav: <%= @domain.registrant_street %> -Linn: <%= @domain.registrant_city %> -Riik: <%= @domain.registrant_country %> +Tänav: <%= @params[:registrant_street] %> +Linn: <%= @params[:registrant_city] %> +Riik: <%= @params[:registrant_country] %> -Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiaks lõpule vaid juhul, kui domeeni hetkel kehtiv registreerija <%= @old_registrant.name %> omanikuvahetuse tähtaegselt kinnitab. +Juhime Teie tähelepanu asjaolule, et omanikuvahetuse protseduur viiaks lõpule vaid juhul, kui domeeni hetkel kehtiv registreerija <%= @params[:old_registrant_name] %> omanikuvahetuse tähtaegselt kinnitab. -Juhul kui <%= @old_registrant.name %> lükkab omanikuvahtuse taotluse tagasi või ei anna kinnitust enne <%= Setting.expire_pending_confirmation %> tundi, omanikuvahetuse protseduur tühistatakse. +Juhul kui <%= @params[:old_registrant_name] %> lükkab omanikuvahtuse taotluse tagasi või ei anna kinnitust enne <%= Setting.expire_pending_confirmation %> tundi, omanikuvahetuse protseduur tühistatakse. -Küsimuste korral palun võtke ühendust registripidajaga <%= @domain.registrar_name %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad +Küsimuste korral palun võtke ühendust registripidajaga <%= @params[:registrar_name] %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad Lugupidamisega Eesti Interneti SA @@ -28,20 +28,20 @@ Eesti Interneti SA Hi, -Registrant change process for the domain <%= @domain.name %> has been started. +Registrant change process for the domain <%= @params[:name] %> has been started. New registrant: -Name: <%= @domain.registrant_name %> -<% if @domain.registrant.priv? %> -Personal code: <%= @domain.registrant_ident %> +Name: <%= @params[:registrant_name] %> +<% if @params[:registrant_priv] %> +Personal code: <%= @params[:registrant_ident] %> <% else %> -Business Registry code: <%= @domain.registrant_ident %> +Business Registry code: <%= @params[:registrant_ident] %> <% end %> -Street: <%= @domain.registrant_street %> -City: <%= @domain.registrant_city %> -Country: <%= @domain.registrant_country %> +Street: <%= @params[:registrant_street] %> +City: <%= @params[:registrant_city] %> +Country: <%= @params[:registrant_country] %> -Please contact to your registrar <%= @domain.registrar_name %> if you have any questions. +Please contact to your registrar <%= @params[:registrar_name] %> if you have any questions. Best Regards, Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.html.erb b/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.html.erb index 94672f176..1f9acf666 100644 --- a/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.html.erb +++ b/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.html.erb @@ -1,8 +1,8 @@ Tere,

-Domeeni <%= @domain.name %> registreerija <%= @new_registrant_name %> on domeeni registreerija vahetamise taotluse tagasi lükanud. +Domeeni <%= @params[:name] %> registreerija <%= @params[:old_registrant_name] %> on domeeni registreerija vahetamise taotluse tagasi lükanud.

-Küsimuste korral palun võtke ühendust registripidajaga <%= @domain.registrar_name %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad +Küsimuste korral palun võtke ühendust registripidajaga <%= @params[:registrar_name] %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad

Lugupidamisega,
Eesti Interneti SA @@ -11,9 +11,9 @@ Eesti Interneti SA

Hi,

-Registrant change was declined for the domain <%= @domain.name %>. +Registrant change was declined for the domain <%= @params[:name] %>.

-Please contact to your registrar <%= @domain.registrar_name %> if you have any questions. +Please contact to your registrar <%= @params[:registrar_name] %> if you have any questions.

Best Regards,
Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.text.erb b/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.text.erb index afdf06325..38a83e1b3 100644 --- a/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.text.erb +++ b/app/views/mailers/domain_mailer/pending_update_rejected_notification_for_new_registrant.text.erb @@ -1,8 +1,8 @@ Tere, -Domeeni <%= @domain.name %> registreerija <%= @new_registrant_name %> on domeeni registreerija vahetamise taotluse tagasi lükanud. +Domeeni <%= @params[:name] %> registreerija <%= @params[:old_registrant_name] %> on domeeni registreerija vahetamise taotluse tagasi lükanud. -Küsimuste korral palun võtke ühendust registripidajaga <%= @domain.registrar_name %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad +Küsimuste korral palun võtke ühendust registripidajaga <%= @params[:registrar_name] %>, kelle kontaktid leiate http://internet.ee/registripidajad/akrediteeritud-registripidajad Lugupidamisega Eesti Interneti SA @@ -11,9 +11,9 @@ Eesti Interneti SA Hi, -Registrant change was declined for the domain <%= @domain.name %>. +Registrant change was declined for the domain <%= @params[:name] %>. -Please contact to your registrar <%= @domain.registrar_name %> if you have any questions. +Please contact to your registrar <%= @params[:registrar_name] %> if you have any questions. Best Regards, Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.html.erb b/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.html.erb index c62cb5561..dc26a9c1c 100644 --- a/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.html.erb +++ b/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.html.erb @@ -1,23 +1,23 @@ Tere,

-Registrisse laekus taotlus domeeni <%= @domain.name %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @domain.registrar_name %> +Registrisse laekus taotlus domeeni <%= @params[:name] %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @params[:registrar_name] %>

-Uued registreerija andmed:
-Nimi: <%= @domain.registrant_name %>
-<% if @domain.registrant.priv? %> -Isikukood: <%= @domain.registrant_ident %>
+Uue registreerija andmed:
+Nimi: <%= @params[:registrant_name] %>
+<% if @params[:registrant_priv] %> +Isikukood: <%= @params[:registrant_ident] %>
<% else %> -Äriregistrikood: <%= @domain.registrant_ident %>
+Äriregistrikood: <%= @params[:registrant_ident] %>
<% end %> -Tänav: <%= @domain.registrant_street %>
-Linn: <%= @domain.registrant_city %>
-Riik: <%= @domain.registrant_country %> +Tänav: <%= @params[:registrant_street] %>
+Linn: <%= @params[:registrant_city] %>
+Riik: <%= @params[:registrant_country] %>

Taotlus on aktiivne <%= Setting.expire_pending_confirmation %> tundi ja lükatakse automaatselt tagasi kui te seda enne ise ei kinnita või tagasi lükka.

Muudatuse kinnitamiseks külastage palun allolevat võrgulehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan:
-<%= link_to @verification_url, @verification_url %> +<%= link_to @params[:verification_url], @params[:verification_url] %>

Lugupidamisega
Eesti Interneti SA @@ -26,23 +26,23 @@ Eesti Interneti SA

Hi,

-Application for changing registrant of your domain <%= @domain.name %> has been filed. Please make sure that the update and information are correct. Incase of problems please turn to your registrar. Your registrar is <%= @domain.registrar_name %> +Application for changing registrant of your domain <%= @params[:name] %> has been filed. Please make sure that the update and information are correct. Incase of problems please turn to your registrar. Your registrar is <%= @params[:registrar_name] %>

New registrant:
-Name: <%= @domain.registrant_name %>
-<% if @domain.registrant.priv? %> -Personal code: <%= @domain.registrant_ident %>
+Name: <%= @params[:registrant_name] %>
+<% if @params[:registrant_priv] %> +Personal code: <%= @params[:registrant_ident] %>
<% else %> -Business Registry code: <%= @domain.registrant_ident %>
+Business Registry code: <%= @params[:registrant_ident] %>
<% end %> -Street: <%= @domain.registrant_street %>
-City: <%= @domain.registrant_city %>
-Country: <%= @domain.registrant_country %> +Street: <%= @params[:registrant_street] %>
+City: <%= @params[:registrant_city] %>
+Country: <%= @params[:registrant_country] %>

The application will remain in pending status for <%= Setting.expire_pending_confirmation %> hrs and will be automaticcally rejected if it is not approved nor rejected before.

To confirm the update please visit this website, once again review the data and press approve:
-<%= link_to @verification_url, @verification_url %> +<%= link_to @params[:verification_url], @params[:verification_url] %>

Best Regards,
Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.text.erb b/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.text.erb index 04a85bf5e..142004bb6 100644 --- a/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.text.erb +++ b/app/views/mailers/domain_mailer/pending_update_request_for_old_registrant.text.erb @@ -1,21 +1,21 @@ Tere, -Registrisse laekus taotlus domeeni <%= @domain.name %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @domain.registrar_name %> +Registrisse laekus taotlus domeeni <%= @params[:name] %> registreerija vahetuseks. Palun veenduge, et muudatus on korrektne ning probleemide korral pöörduge oma registripidaja poole. Teie registripidaja on <%= @params[:registrar_name] %> -Uued registreerija andmed: -Nimi: <%= @domain.registrant_name %> -<% if @domain.registrant.priv? %> -Isikukood: <%= @domain.registrant_ident %> +Uue registreerija andmed: +Nimi: <%= @params[:registrant_name] %> +<% if @params[:registrant_priv] %> +Isikukood: <%= @params[:registrant_ident] %> <% else %> -Äriregistrikood: <%= @domain.registrant_ident %> +Äriregistrikood: <%= @params[:registrant_ident] %> <% end %> -Tänav: <%= @domain.registrant_street %> -Linn: <%= @domain.registrant_city %> -Riik: <%= @domain.registrant_country %> +Tänav: <%= @params[:registrant_street] %> +Linn: <%= @params[:registrant_city] %> +Riik: <%= @params[:registrant_country] %> Taotlus on aktiivne <%= Setting.expire_pending_confirmation %> tundi ja lükatakse automaatselt tagasi kui te seda enne ise ei kinnita või tagasi lükka. Muudatuse kinnitamiseks külastage palun allolevat võrgulehekülge, kontrollige uuesti üle muudatuse andmed ning vajutage nuppu kinnitan: -<%= @verification_url %> +<%= @params[:verification_url] %> Lugupidamisega Eesti Interneti SA @@ -24,22 +24,22 @@ Eesti Interneti SA Hi, -Application for changing registrant of your domain <%= @domain.name %> has been filed. Please make sure that the update and information are correct. Incase of problems please turn to your registrar. Your registrar is <%= @domain.registrar_name %> +Application for changing registrant of your domain <%= @params[:name] %> has been filed. Please make sure that the update and information are correct. Incase of problems please turn to your registrar. Your registrar is <%= @params[:registrar_name] %> New registrant: -Name: <%= @domain.registrant_name %> -<% if @domain.registrant.priv? %> -Personal code: <%= @domain.registrant_ident %> +Name: <%= @params[:registrant_name] %> +<% if @params[:registrant_priv] %> +Personal code: <%= @params[:registrant_ident] %> <% else %> -Business Registry code: <%= @domain.registrant_ident %> +Business Registry code: <%= @params[:registrant_ident] %> <% end %> -Street: <%= @domain.registrant_street %> -City: <%= @domain.registrant_city %> -Country: <%= @domain.registrant_country %> +Street: <%= @params[:registrant_street] %> +City: <%= @params[:registrant_city] %> +Country: <%= @params[:registrant_country] %> The application will remain in pending status for <%= Setting.expire_pending_confirmation %> hrs and will be automaticcally rejected if it is not approved nor rejected before. To confirm the update please visit this website, once again review the data and press approve: -<%= @verification_url %> +<%= @params[:verification_url] %> Best Regards, Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb index eb8352b8e..c7d464f43 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb @@ -1,18 +1,18 @@ Tere,

-Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. +Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.

-Uued registreerija andmed:
-Nimi: <%= @domain.registrant_name %>
-<% if @domain.registrant.priv? %> -Isikukood: <%= @domain.registrant_ident %>
+Uue registreerija andmed:
+Nimi: <%= @params[:registrant_name] %>
+<% if @params[:registrant_priv] %> +Isikukood: <%= @params[:registrant_ident] %>
<% else %> -Äriregistrikood: <%= @domain.registrant_ident %>
+Äriregistrikood: <%= @params[:registrant_ident] %>
<% end %> -Epost: <%= @domain.registrant_email %>
-Tänav: <%= @domain.registrant_street %>
-Linn: <%= @domain.registrant_city %>
-Riik: <%= @domain.registrant_country %> +Epost: <%= @params[:registrant_email] %>
+Tänav: <%= @params[:registrant_street] %>
+Linn: <%= @params[:registrant_city] %>
+Riik: <%= @params[:registrant_country] %>

Lugupidamisega
Eesti Interneti SA @@ -21,19 +21,19 @@ Eesti Interneti SA

Hi,

-Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated. +Process for changing registrant of the domain <%= @params[:name] %> has been approved and the data in the registry is updated.

New registrant:
-Name: <%= @domain.registrant_name %>
-<% if @domain.registrant.priv? %> -Personal code: <%= @domain.registrant_ident %>
+Name: <%= @params[:registrant_name] %>
+<% if @params[:registrant_priv] %> +Personal code: <%= @params[:registrant_ident] %>
<% else %> -Business Registry code: <%= @domain.registrant_ident %>
+Business Registry code: <%= @params[:registrant_ident] %>
<% end %> -E-mail: <%= @domain.registrant_email %>
-Street: <%= @domain.registrant_street %>
-City: <%= @domain.registrant_city %>
-Country: <%= @domain.registrant_country %> +E-mail: <%= @params[:registrant_email] %>
+Street: <%= @params[:registrant_street] %>
+City: <%= @params[:registrant_city] %>
+Country: <%= @params[:registrant_country] %>

Best Regards,
Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb index 503c111f6..115655897 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb @@ -1,18 +1,18 @@ Tere, -Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. +Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. -Uued registreerija andmed: -Nimi: <%= @domain.registrant_name %> -<% if @domain.registrant.priv? %> -Isikukood: <%= @domain.registrant_ident %> +Uue registreerija andmed: +Nimi: <%= @params[:registrant_name] %> +<% if @params[:registrant_priv] %> +Isikukood: <%= @params[:registrant_ident] %> <% else %> -Äriregistrikood: <%= @domain.registrant_ident %> +Äriregistrikood: <%= @params[:registrant_ident] %> <% end %> -Epost: <%= @domain.registrant_email %> -Tänav: <%= @domain.registrant_street %> -Linn: <%= @domain.registrant_city %> -Riik: <%= @domain.registrant_country %> +Epost: <%= @params[:registrant_email] %> +Tänav: <%= @params[:registrant_street] %> +Linn: <%= @params[:registrant_city] %> +Riik: <%= @params[:registrant_country] %> Lugupidamisega Eesti Interneti SA @@ -21,19 +21,19 @@ Eesti Interneti SA Hi, -Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated. +Process for changing registrant of the domain <%= @params[:name] %> has been approved and the data in the registry is updated. New registrant: -Name: <%= @domain.registrant_name %> -<% if @domain.registrant.priv? %> -Personal code: <%= @domain.registrant_ident %> +Name: <%= @params[:registrant_name] %> +<% if @params[:registrant_priv] %> +Personal code: <%= @params[:registrant_ident] %> <% else %> -Business Registry code: <%= @domain.registrant_ident %> +Business Registry code: <%= @params[:registrant_ident] %> <% end %> -E-mail: <%= @domain.registrant_email %> -Street: <%= @domain.registrant_street %> -City: <%= @domain.registrant_city %> -Country: <%= @domain.registrant_country %> +E-mail: <%= @params[:registrant_email] %> +Street: <%= @params[:registrant_street] %> +City: <%= @params[:registrant_city] %> +Country: <%= @params[:registrant_country] %> Best Regards, Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb index bdfda76dc..b41e1f1eb 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb @@ -1,9 +1,18 @@ Tere,

-Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. +Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.

-Uued registreerija:
-Nimi: <%= @domain.registrant_name %> +Uue registreerija andmed:
+Nimi: <%= @params[:new_registrant_name] %>
+<% if @params[:registrant_priv] %> +Isikukood: <%= @params[:registrant_ident] %>
+<% else %> +Äriregistrikood: <%= @params[:registrant_ident] %>
+<% end %> +Epost: <%= @params[:registrant_email] %>
+Tänav: <%= @params[:registrant_street] %>
+Linn: <%= @params[:registrant_city] %>
+Riik: <%= @params[:registrant_country] %>

Lugupidamisega
Eesti Interneti SA @@ -12,10 +21,19 @@ Eesti Interneti SA

Hi,

-Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated. +Process for changing registrant of the domain <%= @params[:name] %> has been approved and the data in the registry is updated.

New registrant:
-Name: <%= @domain.registrant_name %> +Name: <%= @params[:new_registrant_name] %>
+<% if @params[:registrant_priv] %> +Personal code: <%= @params[:registrant_ident] %>
+<% else %> +Business Registry code: <%= @params[:registrant_ident] %>
+<% end %> +E-mail: <%= @params[:registrant_email] %>
+Street: <%= @params[:registrant_street] %>
+City: <%= @params[:registrant_city] %>
+Country: <%= @params[:registrant_country] %>

Best Regards,
Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb index 08fb37fe0..c2efa5af9 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb @@ -1,9 +1,19 @@ Tere, -Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. +Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. -Uued registreerija: -Nimi: <%= @domain.registrant_name %> +Uue registreerija andmed: +Nimi: <%= @params[:new_registrant_name] %> + +<% if @params[:registrant_priv] %> +Isikukood: <%= @params[:registrant_ident] %> +<% else %> +Äriregistrikood: <%= @params[:registrant_ident] %> +<% end %> +Epost: <%= @params[:registrant_email] %> +Tänav: <%= @params[:registrant_street] %> +Linn: <%= @params[:registrant_city] %> +Riik: <%= @params[:registrant_country] %> Lugupidamisega Eesti Interneti SA @@ -12,10 +22,20 @@ Eesti Interneti SA Hi, -Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated. +Process for changing registrant of the domain <%= @params[:name] %> has been approved and the data in the registry is updated. New registrant: -Name: <%= @domain.registrant_name %> +Name: <%= @params[:new_registrant_name] %> + +<% if @params[:registrant_priv] %> +Personal code: <%= @params[:registrant_ident] %> +<% else %> +Business Registry code: <%= @params[:registrant_ident] %> +<% end %> +E-mail: <%= @params[:registrant_email] %> +Street: <%= @params[:registrant_street] %> +City: <%= @params[:registrant_city] %> +Country: <%= @params[:registrant_country] %> Best Regards, Estonian Internet Foundation diff --git a/app/views/registrar/contacts/download_list.haml b/app/views/registrar/contacts/download_list.haml new file mode 100644 index 000000000..b8944d254 --- /dev/null +++ b/app/views/registrar/contacts/download_list.haml @@ -0,0 +1,30 @@ +!!! +%html + %head + %meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"} + %title Contacts + %body + .row + .col-md-12 + .table-responsive + %table.table.table-hover.table-bordered.table-condensed + %thead + %tr + %th{class: 'col-xs-2'} + =t(:name) + %th{class: 'col-xs-2'} + =t(:id) + %th{class: 'col-xs-2'} + =t(:ident) + %th{class: 'col-xs-2'} + =t(:created_at) + %th{class: 'col-xs-2'} + =t(:registrar) + %tbody + - @contacts.each do |contact| + %tr + %td= contact + %td= contact.code + %td= ident_for(contact) + %td= l(contact.created_at, format: :short) + %td= contact.registrar diff --git a/app/views/registrar/contacts/index.haml b/app/views/registrar/contacts/index.haml index 401df706d..ae93a82fd 100644 --- a/app/views/registrar/contacts/index.haml +++ b/app/views/registrar/contacts/index.haml @@ -2,23 +2,130 @@ = link_to(t(:new), new_registrar_contact_path, class: 'btn btn-primary') = render 'shared/title', name: t(:contacts) -- if @response - .table-responsive - %table.table.table-hover.table-condensed - %thead - %tr - %th{class: 'col-xs-3'}= t(:name) - %th{class: 'col-xs-3'}= t(:id) - %th{class: 'col-xs-3'}= t(:ident) - %th{class: 'col-xs-3'}= t(:actions) - %tbody - - @contacts.each do |c| - %tr - %td= link_to(c[:name], registrar_contact_path(id: c[:code])) - %td= c[:code] - %td= ident_for(c) - %td - = link_to(t(:edit), edit_registrar_contact_path(c[:code]), class: 'btn btn-primary btn-xs') - = link_to(t(:delete), delete_registrar_contact_path(c[:code]), class: 'btn btn-default btn-xs') +.row + .col-md-12 + = search_form_for [:registrar, @q], html: { style: 'margin-bottom: 0;', class: 'js-form', autocomplete: 'off' } do |f| + .row + .col-md-3 + .form-group + = f.label :name + = f.search_field :name_matches, value: params[:q][:name_matches], class: 'form-control', placeholder: t(:name) + .col-md-3 + .form-group + = f.label t(:id) + = f.search_field :code_eq, class: 'form-control', placeholder: t(:id) + .col-md-3 + .form-group + = f.label t(:ident) + = f.search_field :ident_matches, class: 'form-control', placeholder: t(:ident) + .col-md-3 + .form-group + = label_tag t(:ident_type) + = select_tag '[q][ident_type_eq]', options_for_select(Contact::IDENT_TYPES, params[:q][:ident_type_eq]), { include_blank: true, placeholder: t(:choose), class: 'form-control selectize' } + .row + .col-md-3 + .form-group + = f.label t(:email) + = f.search_field :email_matches, class: 'form-control', placeholder: t(:email) + .col-md-3 + .form-group + = label_tag t(:country) + = select_tag '[q][country_code_eq]', SortedCountry.all_options(params[:q][:country_code_eq]), { include_blank: true, placeholder: t(:choose), class: 'form-control selectize' } + .col-md-3 + .form-group + = f.label t(:is_registrant) + %div + = f.check_box :registrant_domains_id_not_null + .col-md-3 + .form-group + = label_tag t(:contact_type) + = select_tag '[q][domain_contacts_type_in]', options_for_select([['admin', 'AdminDomainContact'], ['tech', 'TechDomainContact']], params[:q][:domain_contacts_type_in]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' } + .row + .col-md-3 + .form-group + = f.label t(:registrar) + = f.select :registrar_id_eq, Registrar.all.map { |x| [x, x.id] }, { include_blank: true }, class: 'form-control selectize', placeholder: t(:choose) + .col-md-3 + .form-group + = f.label t(:created_at_from) + = f.search_field :created_at_gteq, value: params[:q][:created_at_gteq], class: 'form-control datepicker', placeholder: t(:created_at_from) + .col-md-3 + .form-group + = f.label t(:created_at_until) + = f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control datepicker', placeholder: t(:created_at_until) + .col-md-3 + .form-group + = f.label t(:updated_at) + = f.search_field :updated_at_gteq, value: params[:q][:updated_at_gteq], class: 'form-control datepicker', placeholder: t(:updated_at) + .row + .col-md-6 + .form-group + = label_tag t(:status) + = select_tag :statuses_contains, options_for_select(Contact::STATUSES, params[:statuses_contains]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' } + .col-md-3 + .form-group + = label_tag t(:results_per_page) + = text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page) + .col-md-3{style: 'padding-top: 25px;'} + %button.btn.btn-primary +   + %span.glyphicon.glyphicon-search +   + %button.btn.btn-default.js-reset-form + = t(:clear_fields) + .row + .col-md-3 + .btn-group{:role => "group"} + %button.btn.btn-default.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} + Download + %span.caret + %ul.dropdown-menu + %li= link_to 'PDF', download_list_registrar_contacts_path(q: params[:q], format: "pdf") + %li= link_to 'CSV', download_list_registrar_contacts_path(q: params[:q], format: "csv") + .col-md-3 + .col-md-3 + .col-md-3 - = paginate @paginatable_array +%hr +.row + .col-md-12 + .table-responsive + %table.table.table-hover.table-bordered.table-condensed + %thead + %tr + %th{class: 'col-xs-2'} + = sort_link(@q, 'name', t(:name)) + %th{class: 'col-xs-2'} + = sort_link(@q, 'code', t(:id)) + %th{class: 'col-xs-2'} + = sort_link(@q, 'ident', t(:ident)) + %th{class: 'col-xs-2'} + = sort_link(@q, 'email', t(:created_at)) + %th{class: 'col-xs-2'} + = sort_link(@q, 'registrar_name', t(:registrar)) + %th{class: 'col-xs-2'}= t(:actions) + %tbody + - @contacts.each do |contact| + %tr + %td= link_to(contact.name, registrar_contact_path(id: contact.code)) + %td= contact.code + %td= ident_for(contact) + %td= l(contact.created_at, format: :short) + %td + - if contact.registrar + = contact.registrar + %td + = link_to(t(:edit), edit_registrar_contact_path(contact.code), class: 'btn btn-primary btn-xs') + = link_to(t(:delete), delete_registrar_contact_path(contact.code), class: 'btn btn-default btn-xs') + +.row + .col-md-6 + = paginate @contacts + .col-md-6.text-right + .pagination + = t(:result_count, count: @contacts.total_count) + +:coffee + $(".js-reset-form").on "click", (e) -> + e.preventDefault(); + window.location = "#{registrar_contacts_path}" diff --git a/app/views/registrar/contacts/partials/_general.haml b/app/views/registrar/contacts/partials/_general.haml index 37bd87555..462bf35a0 100644 --- a/app/views/registrar/contacts/partials/_general.haml +++ b/app/views/registrar/contacts/partials/_general.haml @@ -6,7 +6,7 @@ %dt= t(:id) %dd= @contact.id - %dt= t(:password) + %dt= t(:authinfo_pw) %dd = text_field_tag :password, @contact.password, readonly: true, class: 'partially-hidden' diff --git a/app/views/registrar/domains/partials/_general.haml b/app/views/registrar/domains/partials/_general.haml index cd16079dd..4eb5285e7 100644 --- a/app/views/registrar/domains/partials/_general.haml +++ b/app/views/registrar/domains/partials/_general.haml @@ -3,7 +3,7 @@ %h3.panel-title= t(:general) .panel-body %dl.dl-horizontal - %dt= t(:password) + %dt= t(:authinfo_pw) %dd= @data.css('pw').text.present? ? @data.css('pw').text : t('hidden') - if @data.css('pw').text.blank? diff --git a/app/views/registrar/polls/show.haml b/app/views/registrar/polls/show.haml index 90a5bb02a..e013bad7b 100644 --- a/app/views/registrar/polls/show.haml +++ b/app/views/registrar/polls/show.haml @@ -30,7 +30,7 @@ %dt= t(:domain_name) %dd= @data.css('name').text - %dt= t(:password) + %dt= t(:authinfo_pw) %dd= @data.css('pw').text - if @data.css('relative').text.present? diff --git a/config/locales/en.yml b/config/locales/en.yml index 16e643b16..893fe5665 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -280,6 +280,7 @@ en: domain_details: 'Domain details' registered_at: 'Registered at' password: 'Password' + authinfo_pw: 'AuthInfo pw' valid_from: 'Valid from' general: 'General' contacts: 'Contacts' @@ -554,6 +555,7 @@ en: username: 'Username' password: 'Password' + authinfo_pw: 'AuthInfo pw' log_in: 'Log in' domains: 'Domains' register: 'Register' @@ -904,7 +906,7 @@ en: edit_zone: 'Edit zone' there_are_count_domains_in_this_zone: 'There are %{count} domains in this zone' poll_pending_update_confirmed_by_registrant: 'Registrant confirmed domain update' - poll_pending_update_rejected_by_registranti: 'Registrant rejected domain update' + poll_pending_update_rejected_by_registrant: 'Registrant rejected domain update' poll_pending_delete_rejected_by_registrant: 'Registrant rejected domain deletion' poll_pending_delete_confirmed_by_registrant: 'Registrant confirmed domain deletion' manage: Manage diff --git a/config/routes.rb b/config/routes.rb index c1cc98697..9dd7faf7d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -74,6 +74,7 @@ Rails.application.routes.draw do collection do get 'check' + get 'download_list' end end