diff --git a/Gemfile b/Gemfile index efa8b1f81..2b2b5407b 100644 --- a/Gemfile +++ b/Gemfile @@ -12,6 +12,7 @@ gem 'rails', '4.2.4' # when update, all initializers eis_custom files nee gem 'iso8601', '0.8.6' # for dates and times gem 'hashie-forbidden_attributes', '0.1.1' gem 'SyslogLogger', '2.0', require: 'syslog/logger' +gem 'rest-client' gem 'parallel' # load env diff --git a/Gemfile.lock b/Gemfile.lock index 4b7c74561..ab901068e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -188,6 +188,8 @@ GEM nokogiri (>= 1.4.0) savon (>= 2.4.0) docile (1.1.5) + domain_name (0.5.25) + unf (>= 0.0.5, < 1.0.0) epp-xml (1.0.4) activesupport (~> 4.1) builder (~> 3.2) @@ -261,6 +263,8 @@ GEM nokogiri (~> 1.6.0) ruby_parser (~> 3.5) html5_validators (1.2.2) + http-cookie (1.0.2) + domain_name (~> 0.5) httpclient (2.6.0.1) httpi (2.4.1) rack @@ -320,6 +324,7 @@ GEM multi_json (1.11.2) multi_xml (0.5.5) nenv (0.2.0) + netrc (0.11.0) newrelic_rpm (3.12.0.288) nokogiri (1.6.6.2) mini_portile (~> 0.6.0) @@ -413,6 +418,10 @@ GEM request_store (1.1.0) responders (2.1.0) railties (>= 4.2.0, < 5) + rest-client (1.8.0) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 3.0) + netrc (~> 0.7) rspec (3.3.0) rspec-core (~> 3.3.0) rspec-expectations (~> 3.3.0) @@ -516,6 +525,9 @@ GEM uglifier (2.7.1) execjs (>= 0.3.0) json (>= 1.8.0) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.1) unicorn (4.9.0) kgio (~> 2.6) rack @@ -619,6 +631,7 @@ DEPENDENCIES rails-settings-cached (= 0.4.1) rake ransack (= 1.5.1) + rest-client rspec-rails (= 3.3.2) rubocop (= 0.32.1) rubycritic (= 1.4.0) diff --git a/app/controllers/admin/account_activities_controller.rb b/app/controllers/admin/account_activities_controller.rb index 1c447d8a6..0f095734f 100644 --- a/app/controllers/admin/account_activities_controller.rb +++ b/app/controllers/admin/account_activities_controller.rb @@ -12,11 +12,27 @@ class Admin::AccountActivitiesController < AdminController logger.warn('Invalid date') end + balance_params = params[:q].deep_dup + + if balance_params[:created_at_gteq] + balance_params.delete('created_at_gteq') + end + @q = AccountActivity.includes(:invoice, account: :registrar).search(params[:q]) + @b = AccountActivity.search(balance_params) @q.sorts = 'id desc' if @q.sorts.empty? + @account_activities = @q.result.page(params[:page]).per(params[:results_per_page]) + sort = @account_activities.orders.map(&:to_sql).join(",") + + if params[:page] && params[:page].to_i > 1 + @sum = @q.result.reorder(sort).limit(@account_activities.offset_value) + @b.result.where.not(id: @q.result.map(&:id)) + else + @sum = @b.result.where.not(id: @q.result.map(&:id)) + end + respond_to do |format| - format.html { @account_activities = @q.result.page(params[:page]) } + format.html format.csv do send_data @q.result.to_csv, filename: "account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv" end diff --git a/app/controllers/admin/blocked_domains_controller.rb b/app/controllers/admin/blocked_domains_controller.rb index 2df3f90d9..49cc65675 100644 --- a/app/controllers/admin/blocked_domains_controller.rb +++ b/app/controllers/admin/blocked_domains_controller.rb @@ -2,22 +2,54 @@ class Admin::BlockedDomainsController < AdminController load_and_authorize_resource def index - bd = BlockedDomain.first_or_initialize - @blocked_domains = bd.names.join("\n") + + params[:q] ||= {} + domains = BlockedDomain.all.order(:name) + @q = domains.search(params[:q]) + @domains = @q.result.page(params[:page]) + @domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i > 0 + + end + + def new + + @domain = BlockedDomain.new + end def create - names = params[:blocked_domains].split("\r\n").map(&:strip) - bd = BlockedDomain.first_or_create + @domain = BlockedDomain.new(blocked_domain_params) - if bd.update(names: names) - flash[:notice] = I18n.t('record_updated') - redirect_to :back + if @domain.save + flash[:notice] = I18n.t('domain_added') + redirect_to admin_blocked_domains_path else - @blocked_domains = params[:blocked_domains] - flash.now[:alert] = I18n.t('failed_to_update_record') - render :index + flash.now[:alert] = I18n.t('failed_to_add_domain') + render 'new' + end + + end + + def delete + + if BlockedDomain.find(params[:id]).destroy + flash[:notice] = I18n.t('domain_deleted') + redirect_to admin_blocked_domains_path + else + flash.now[:alert] = I18n.t('failed_to_delete_domain') + redirect_to admin_blocked_domains_path end end -end + + + def blocked_domain_params + params.require(:blocked_domain).permit(:name) + end + + private + + def set_domain + @domain = BlockedDomain.find(params[:id]) + end +end \ No newline at end of file diff --git a/app/controllers/admin/contacts_controller.rb b/app/controllers/admin/contacts_controller.rb index a1df165d2..960d74002 100644 --- a/app/controllers/admin/contacts_controller.rb +++ b/app/controllers/admin/contacts_controller.rb @@ -4,8 +4,14 @@ class Admin::ContactsController < AdminController def index params[:q] ||= {} - @q = Contact.includes(:registrar).search(params[:q]) - @contacts = @q.result.page(params[:page]) + search_params = params[:q].deep_dup + + if search_params[:domain_contacts_type_in].is_a?(Array) && search_params[:domain_contacts_type_in].delete('registrant') + search_params[:registrant_domains_id_not_null] = 1 + end + + @q = Contact.includes(:registrar).search(search_params) + @contacts = @q.result(distinct: :true).page(params[:page]) if params[:statuses_contains] contacts = Contact.includes(:registrar).where( @@ -16,8 +22,8 @@ class Admin::ContactsController < AdminController end normalize_search_parameters do - @q = contacts.search(params[:q]) - @contacts = @q.result.page(params[:page]) + @q = contacts.search(search_params) + @contacts = @q.result(distinct: :true).page(params[:page]) end @contacts = @contacts.per(params[:results_per_page]) if params[:results_per_page].to_i > 0 diff --git a/app/controllers/admin/invoices_controller.rb b/app/controllers/admin/invoices_controller.rb index 5aa6d4438..709dc866a 100644 --- a/app/controllers/admin/invoices_controller.rb +++ b/app/controllers/admin/invoices_controller.rb @@ -23,7 +23,7 @@ class Admin::InvoicesController < AdminController def index @q = Invoice.includes(:account_activity).search(params[:q]) - @q.sorts = 'id desc' if @q.sorts.empty? + @q.sorts = 'number desc' if @q.sorts.empty? @invoices = @q.result.page(params[:page]) end 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/admin/registrars_controller.rb b/app/controllers/admin/registrars_controller.rb index c0d28908f..cf8c89505 100644 --- a/app/controllers/admin/registrars_controller.rb +++ b/app/controllers/admin/registrars_controller.rb @@ -6,7 +6,7 @@ class Admin::RegistrarsController < AdminController end def index - @q = Registrar.ordered.search(params[:q]) + @q = Registrar.joins(:accounts).ordered.search(params[:q]) @registrars = @q.result.page(params[:page]) end diff --git a/app/controllers/admin/reserved_domains_controller.rb b/app/controllers/admin/reserved_domains_controller.rb index 57e4b8ed3..7de8d9891 100644 --- a/app/controllers/admin/reserved_domains_controller.rb +++ b/app/controllers/admin/reserved_domains_controller.rb @@ -1,51 +1,68 @@ class Admin::ReservedDomainsController < AdminController load_and_authorize_resource + before_action :set_domain, only: [:edit, :update] def index - names = ReservedDomain.pluck(:names).each_with_object({}){|e_h,h| h.merge!(e_h)} - names.names = nil if names.blank? - @reserved_domains = names.to_yaml.gsub(/---.?\n/, '').gsub(/\.\.\..?\n/, '') + + params[:q] ||= {} + domains = ReservedDomain.all.order(:name) + @q = domains.search(params[:q]) + @domains = @q.result.page(params[:page]) + @domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i > 0 + + end + + def new + @domain = ReservedDomain.new + end + + def edit end def create - @reserved_domains = params[:reserved_domains] - begin - params[:reserved_domains] = "---\n" if params[:reserved_domains].blank? - names = YAML.load(params[:reserved_domains]) - fail if names == false - rescue - flash.now[:alert] = I18n.t('invalid_yaml') - logger.warn 'Invalid YAML' - render :index and return - end + @domain = ReservedDomain.new(reserved_domain_params) - result = true - ReservedDomain.transaction do - # removing old ones - existing = ReservedDomain.any_of_domains(names.keys).pluck(:id) - ReservedDomain.where.not(id: existing).delete_all - - #updating and adding - names.each do |name, psw| - rec = ReservedDomain.by_domain(name).first - rec ||= ReservedDomain.new - rec.names = {name => psw} - - unless rec.save - result = false - raise ActiveRecord::Rollback - end - end - end - - - if result - flash[:notice] = I18n.t('record_updated') - redirect_to :back + if @domain.save + flash[:notice] = I18n.t('domain_added') + redirect_to admin_reserved_domains_path else - flash.now[:alert] = I18n.t('failed_to_update_record') - render :index + flash.now[:alert] = I18n.t('failed_to_add_domain') + render 'new' end + + end + + def update + + if @domain.update(reserved_domain_params) + flash[:notice] = I18n.t('domain_updated') + else + flash.now[:alert] = I18n.t('failed_to_update_domain') + end + render 'edit' + + end + + def delete + + if ReservedDomain.find(params[:id]).destroy + flash[:notice] = I18n.t('domain_deleted') + redirect_to admin_reserved_domains_path + else + flash.now[:alert] = I18n.t('failed_to_delete_domain') + redirect_to admin_reserved_domains_path + end + + end + + private + + def reserved_domain_params + params.require(:reserved_domain).permit(:name, :password) + end + + def set_domain + @domain = ReservedDomain.find(params[:id]) end end diff --git a/app/controllers/admin/settings_controller.rb b/app/controllers/admin/settings_controller.rb index 89ccd9ac6..cc49b3b61 100644 --- a/app/controllers/admin/settings_controller.rb +++ b/app/controllers/admin/settings_controller.rb @@ -59,6 +59,7 @@ class Admin::SettingsController < AdminController :transfer_wait_time, :invoice_number_min, :invoice_number_max, + :days_to_keep_business_registry_cache, :days_to_keep_invoices_active, :days_to_keep_overdue_invoices_active, :days_to_renew_domain_before_expire, diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5d051377d..ac26e61a3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -32,7 +32,7 @@ class ApplicationController < ActionController::Base if registrar_request? registrar_root_url elsif registrant_request? - registrant_root_url + registrant_login_url elsif admin_request? admin_root_url end 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/epp_controller.rb b/app/controllers/epp_controller.rb index a0e7d7dce..49be47848 100644 --- a/app/controllers/epp_controller.rb +++ b/app/controllers/epp_controller.rb @@ -361,9 +361,10 @@ class EppController < ApplicationController if request_command == 'login' && frame.present? frame.gsub!(/pw>.+<\//, 'pw>[FILTERED]]+)>([^<])+<\/eis:legalDocument>/, "[FILTERED]") ApiLog::EppLog.create({ - request: frame, + request: trimmed_request, request_command: request_command, request_successful: epp_errors.empty?, request_object: params[:epp_object_type], diff --git a/app/controllers/registrant/contacts_controller.rb b/app/controllers/registrant/contacts_controller.rb new file mode 100644 index 000000000..d3a0ddff8 --- /dev/null +++ b/app/controllers/registrant/contacts_controller.rb @@ -0,0 +1,8 @@ +class Registrant::ContactsController < RegistrantController + + def show + @contact = Contact.find(params[:id]) + authorize! :read, @contact + @contact.valid? + end +end \ No newline at end of file diff --git a/app/controllers/registrant/domains_controller.rb b/app/controllers/registrant/domains_controller.rb index 4bba945a8..bf7ce37bb 100644 --- a/app/controllers/registrant/domains_controller.rb +++ b/app/controllers/registrant/domains_controller.rb @@ -1,5 +1,64 @@ class Registrant::DomainsController < RegistrantController + def index - authorize! :view, :registrant_domains + authorize! :view, :registrant_domains + params[:q] ||= {} + normalize_search_parameters do + @q = domains.search(params[:q]) + @domains = @q.result.page(params[:page]) end -end + @domains = @domains.per(params[:results_per_page]) if params[:results_per_page].to_i > 0 + end + + def show + @domain = Domain.find(params[:id]) + if !(domains.include?(@domain) || @domain.valid?) + redirect_to registrant_domains_path + end + authorize! :read, @domain + end + + def set_domain + @domain = Domain.find(params[:id]) + end + + def download_list + authorize! :view, :registrant_domains + params[:q] ||= {} + normalize_search_parameters do + @q = domains.search(params[:q]) + @domains = @q + end + + respond_to do |format| + format.csv { render text: @domains.result.to_csv } + format.pdf do + pdf = @domains.result.pdf(render_to_string('registrant/domains/download_list', layout: false)) + send_data pdf, filename: 'domains.pdf' + end + end + end + + def domains + ident_cc, ident = @current_user.registrant_ident.split '-' + begin + BusinessRegistryCache.fetch_associated_domains ident, ident_cc + rescue Soap::Arireg::NotAvailableError => error + flash[:notice] = I18n.t(error.json[:message]) + Rails.logger.fatal("[EXCEPTION] #{error.to_s}") + current_user.domains + end + 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 \ No newline at end of file diff --git a/app/controllers/registrant/registrants_controller.rb b/app/controllers/registrant/registrants_controller.rb new file mode 100644 index 000000000..adc1e0b82 --- /dev/null +++ b/app/controllers/registrant/registrants_controller.rb @@ -0,0 +1,8 @@ +class Registrant::RegistrantsController < RegistrantController + + def show + @contact = Registrant.find(params[:id]) + authorize! :read, @contact + @contact.valid? + end +end diff --git a/app/controllers/registrant/registrars_controller.rb b/app/controllers/registrant/registrars_controller.rb new file mode 100644 index 000000000..d0630b73a --- /dev/null +++ b/app/controllers/registrant/registrars_controller.rb @@ -0,0 +1,7 @@ +class Registrant::RegistrarsController < RegistrantController + + def show + @registrar = Registrar.find(params[:id]) + authorize! :read, @registrar + end +end diff --git a/app/controllers/registrant/sessions_controller.rb b/app/controllers/registrant/sessions_controller.rb index f0a292137..91589d510 100644 --- a/app/controllers/registrant/sessions_controller.rb +++ b/app/controllers/registrant/sessions_controller.rb @@ -6,15 +6,10 @@ class Registrant::SessionsController < Devise::SessionsController # rubocop: disable Metrics/AbcSize def id - if Rails.env.development? - sign_in(RegistrantUser.find_or_create_by_idc_data('test'), event: :authentication) - return redirect_to registrant_root_url - end + id_code, id_issuer = request.env['SSL_CLIENT_S_DN'], request.env['SSL_CLIENT_I_DN_O'] + id_code, id_issuer = 'test', RegistrantUser::ACCEPTED_ISSUER if Rails.env.development? - logger.error request.env['SSL_CLIENT_S_DN'] - logger.error request.env['SSL_CLIENT_S_DN'].encoding - logger.error request.env['SSL_CLIENT_I_DN_O'] - @user = RegistrantUser.find_or_create_by_idc_data(request.env['SSL_CLIENT_S_DN'], request.env['SSL_CLIENT_I_DN_O']) + @user = RegistrantUser.find_or_create_by_idc_data(id_code, id_issuer) if @user sign_in(@user, event: :authentication) redirect_to registrant_root_url diff --git a/app/controllers/registrant/whois_controller.rb b/app/controllers/registrant/whois_controller.rb index 71d29dd76..b44a0bb67 100644 --- a/app/controllers/registrant/whois_controller.rb +++ b/app/controllers/registrant/whois_controller.rb @@ -1,5 +1,9 @@ class Registrant::WhoisController < RegistrantController def index authorize! :view, :registrant_whois + + if params[:domain_name].present? + @domain = WhoisRecord.find_by(name: params[:domain_name]); + end end end diff --git a/app/controllers/registrar/contacts_controller.rb b/app/controllers/registrar/contacts_controller.rb index 878e29cd2..0581a3cfc 100644 --- a/app/controllers/registrar/contacts_controller.rb +++ b/app/controllers/registrar/contacts_controller.rb @@ -6,8 +6,15 @@ class Registrar::ContactsController < Registrar::DeppController # EPP controller 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]) + + search_params = params[:q].deep_dup + + if search_params[:domain_contacts_type_in].is_a?(Array) && search_params[:domain_contacts_type_in].delete('registrant') + search_params[:registrant_domains_id_not_null] = 1 + end + + if search_params.length == 1 && search_params[:name_matches].present? + @contacts = Contact.find_by(name: search_params[:name_matches]) end if params[:statuses_contains] @@ -19,8 +26,8 @@ class Registrar::ContactsController < Registrar::DeppController # EPP controller end normalize_search_parameters do - @q = contacts.search(params[:q]) - @contacts = @q.result.page(params[:page]) + @q = contacts.search(search_params) + @contacts = @q.result(distinct: :true).page(params[:page]) end @contacts = @contacts.per(params[:results_per_page]) if params[:results_per_page].to_i > 0 diff --git a/app/jobs/domain_update_confirm_job.rb b/app/jobs/domain_update_confirm_job.rb index 28294ef25..098b9853e 100644 --- a/app/jobs/domain_update_confirm_job.rb +++ b/app/jobs/domain_update_confirm_job.rb @@ -3,19 +3,16 @@ class DomainUpdateConfirmJob < Que::Job # it's recommended to keep transaction against job table as short as possible. ActiveRecord::Base.transaction do domain = Epp::Domain.find(domain_id) + domain.is_admin = true case action when RegistrantVerification::CONFIRMED domain.poll_message!(:poll_pending_update_confirmed_by_registrant) - domain.apply_pending_update! do |e| - e.instance_variable_set("@changed_attributes", e.changed_attributes.merge("statuses"=>[])) - end + domain.apply_pending_update! domain.clean_pendings! 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"=>[])) - domain.save + domain.clean_pendings_lowlevel end destroy # it's best to destroy the job in the same transaction end diff --git a/app/jobs/regenerate_registrar_whoises_job.rb b/app/jobs/regenerate_registrar_whoises_job.rb index 10e13a038..68a76c8d3 100644 --- a/app/jobs/regenerate_registrar_whoises_job.rb +++ b/app/jobs/regenerate_registrar_whoises_job.rb @@ -4,7 +4,7 @@ class RegenerateRegistrarWhoisesJob < Que::Job registrar = Registrar.find(registrar_id) registrar.whois_records.select(:id).find_in_batches(batch_size: 20) do |group| - RegenerateWhoisRecordJob.enqueue group.map(&:id) + RegenerateWhoisRecordJob.enqueue group.map(&:id), :id end end end \ No newline at end of file diff --git a/app/jobs/regenerate_whois_record_job.rb b/app/jobs/regenerate_whois_record_job.rb index 6d79e2ea5..051247b7f 100644 --- a/app/jobs/regenerate_whois_record_job.rb +++ b/app/jobs/regenerate_whois_record_job.rb @@ -1,7 +1,7 @@ class RegenerateWhoisRecordJob < Que::Job - def run(ids) + def run(ids, attr = :id) ids.each do |id| - record = WhoisRecord.find_by(id: id) + record = WhoisRecord.find_by(attr => id) return unless record record.save diff --git a/app/jobs/update_whois_record_job.rb b/app/jobs/update_whois_record_job.rb new file mode 100644 index 000000000..b7edb1fdd --- /dev/null +++ b/app/jobs/update_whois_record_job.rb @@ -0,0 +1,16 @@ +class UpdateWhoisRecordJob < Que::Job + + def run(ids, type) + klass = case type + when 'reserved'then ReservedDomain + when 'blocked' then BlockedDomain + else Domain + end + + ids.each do |id| + record = klass.find_by(id: id) + next unless record + record.update_whois_record + end + end +end \ No newline at end of file diff --git a/app/mailers/domain_mailer.rb b/app/mailers/domain_mailer.rb index 3788dd510..28e232a8c 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) @@ -178,8 +97,9 @@ class DomainMailer < ApplicationMailer def expiration_reminder(domain_id) @domain = Domain.find_by(id: domain_id) - return unless @domain + return if @domain.nil? || !@domain.statuses.include?(DomainStatus::EXPIRED) || whitelist_blocked?(@domain.registrant.email) return if whitelist_blocked?(@domain.registrant.email) + mail(to: format(@domain.registrant.email), subject: "#{I18n.t(:expiration_remind_subject, name: @domain.name)} [#{@domain.name}]") @@ -197,4 +117,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/ability.rb b/app/models/ability.rb index cf98cb704..61f1edb2e 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -16,7 +16,7 @@ class Ability @user.roles.each { |role| send(role) } if @user.roles when 'ApiUser' @user.roles.each { |role| send(role) } if @user.roles - when 'RegistrantUser' + when 'RegistrantUser' static_registrant end @@ -117,9 +117,11 @@ class Ability end def static_registrant + customer_service can :manage, :registrant_domains can :manage, :registrant_whois can :manage, Depp::Domain + can :manage, Domain end def user diff --git a/app/models/bank_link.rb b/app/models/bank_link.rb index 31be3e222..29857951f 100644 --- a/app/models/bank_link.rb +++ b/app/models/bank_link.rb @@ -32,7 +32,7 @@ class BankLink hash["VK_AMOUNT"] = number_with_precision(invoice.sum_cache, :precision => 2, :separator => ".") hash["VK_CURR"] = invoice.currency hash["VK_REF"] = "" - hash["VK_MSG"] = "Order nr. #{invoice.number}" + hash["VK_MSG"] = invoice.description hash["VK_RETURN"] = controller.registrar_return_payment_with_url(type) hash["VK_CANCEL"] = controller.registrar_return_payment_with_url(type) hash["VK_DATETIME"] = Time.now.strftime("%Y-%m-%dT%H:%M:%S%z") @@ -101,6 +101,7 @@ class BankLink transaction.buyer_iban = params["VK_SND_ACC"] transaction.buyer_name = params["VK_SND_NAME"] transaction.paid_at = Time.parse(params["VK_T_DATETIME"]) + transaction.save! transaction.autobind_invoice end diff --git a/app/models/bank_transaction.rb b/app/models/bank_transaction.rb index 2e5b90a2e..1a34965bf 100644 --- a/app/models/bank_transaction.rb +++ b/app/models/bank_transaction.rb @@ -2,6 +2,7 @@ class BankTransaction < ActiveRecord::Base include Versions belongs_to :bank_statement has_one :account_activity + has_many :directo_records, as: :item, class_name: 'Directo'# Deprecated scope :unbinded, lambda { where('id NOT IN (SELECT bank_transaction_id FROM account_activities where bank_transaction_id IS NOT NULL)') @@ -16,21 +17,32 @@ class BankTransaction < ActiveRecord::Base account_activity.invoice end + + def invoice_num + return @invoice_no if defined?(@invoice_no) + + match = description.match(/^[^\d]*(\d+)/) + return unless match + + @invoice_no = match[1].try(:to_i) + end + + def invoice + @invoice ||= registrar.invoices.find_by(number: invoice_num) if registrar + end + + def registrar + @registrar ||= Registrar.find_by(reference_no: reference_no) + end + + # For successful binding, reference number, invoice id and sum must match with the invoice # rubocop: disable Metrics/PerceivedComplexity # rubocop: disable Metrics/CyclomaticComplexity def autobind_invoice return if binded? - registrar = Registrar.find_by(reference_no: reference_no) return unless registrar - - match = description.match(/^[^\d]*(\d+)/) - return unless match - - invoice_no = match[1].to_i - return unless invoice_no - - invoice = registrar.invoices.find_by(number: invoice_no) + return unless invoice_num return unless invoice return if invoice.binded? diff --git a/app/models/blocked_domain.rb b/app/models/blocked_domain.rb index 2a646a74f..252539e17 100644 --- a/app/models/blocked_domain.rb +++ b/app/models/blocked_domain.rb @@ -1,5 +1,56 @@ class BlockedDomain < ActiveRecord::Base include Versions + before_save :generate_data + before_destroy :remove_data +validates :name, domain_name: true, uniqueness: true - after_initialize -> { self.names = [] if names.nil? } + + class << self + def by_domain name + where(name: name) + end + + def any_of_domains names + where(name: names) + end + end + + def name= val + super SimpleIDN.to_unicode(val) + end + + def generate_data + return if Domain.where(name: name).any? + + @json = generate_json + @body = generate_body + update_whois_server + end + + alias_method :update_whois_record, :generate_data + + def update_whois_server + wr = Whois::Record.find_or_initialize_by(name: name) + wr.body = @body + wr.json = @json + wr.save + end + + def generate_body + template = Rails.root.join("app/views/for_models/whois_other.erb".freeze) + ERB.new(template.read, nil, "-").result(binding) + end + + def generate_json + h = HashWithIndifferentAccess.new + h[:name] = self.name + h[:status] = 'Blocked' + h + end + + def remove_data + return if Domain.where(name: name).any? + + Whois::Record.where(name: name).delete_all + end end diff --git a/app/models/business_registry_cache.rb b/app/models/business_registry_cache.rb new file mode 100644 index 000000000..5ca1e002c --- /dev/null +++ b/app/models/business_registry_cache.rb @@ -0,0 +1,74 @@ + +=begin +The portal for registrants has to offer an overview of the domains the user is related to directly or through an organisation. +Personal relation is defined by matching the personal identification code associated with a domain and the one acquired on +authentication using electronic ID. Association through a business organisation requires a query to business registry. + + * when user logs in the personal identification code is sent to business registry (using XML service) + * business registry returns the list of business registry codes the user is a board member of + * the list is cached for two days (configurable) + * during that time no new queries are made to business registry for that personal identification code + and the cached organisation code listing is used + * user sees the listing of domains that are associated with him/her directly or through registered organisation + * UI of the portal displays the list of organisation codes and names used to fetch additional domains for the user + (currently by clicking on a username in top right corner of the screen). + Also time and date of the query to the business registry is displayed with the list of organisations. + * if the query to the business registry fails for any reason the list of + domains associated directly with the user is still displayed with an error message indicating a problem + with receiving current list business entities. Outdated list of organisations cannot be used. +=end + +class BusinessRegistryCache < ActiveRecord::Base + + # 1. load domains by business + # 2. load domains by person + def associated_domains + domains = [] + + contact_ids = Contact.where(ident_type: 'org', ident: associated_businesses, ident_country_code: 'EE').pluck(:id) + contact_ids += Contact.where(ident_type: 'priv', ident: ident, ident_country_code: ident_country_code).pluck(:id) + + unless contact_ids.blank? + domains = DomainContact.distinct.where(contact_id: contact_ids).pluck(:domain_id) + end + + Domain.includes(:registrar, :registrant).where(id: domains) + end + + class << self + def fetch_associated_domains(ident_code, ident_cc) + fetch_by_ident_and_cc(ident_code, ident_cc).associated_domains + end + + def fetch_by_ident_and_cc(ident_code, ident_cc) + cache = BusinessRegistryCache.where(ident: ident_code, ident_country_code: ident_cc).first_or_initialize + msg_start = "[Ariregister] #{ident_cc}-#{ident_code}:" + + # fetch new data if cache is expired + if cache.retrieved_on && cache.retrieved_on > (Time.zone.now - Setting.days_to_keep_business_registry_cache.days) + Rails.logger.info("#{msg_start} Info loaded from cache") + return cache + end + + cache.attributes = business_registry.associated_businesses(ident_code, ident_cc) + Rails.logger.info("#{msg_start} Info loaded from server") + + cache.save + cache + end + + def business_registry + Soap::Arireg.new + end + + def purge + STDOUT << "#{Time.zone.now.utc} - Starting Purge of old BusinessRegistry data from cache\n" unless Rails.env.test? + purged = 0 + BusinessRegistryCache.where('retrieved_on < ?', + Time.zone.now < Setting.days_to_keep_business_registry_cache.days).each do |br| + br.destroy and purged += 1 + end + STDOUT << "#{Time.zone.now.utc} - Finished purging #{purged} old BusinessRegistry cache items\n" unless Rails.env.test? + end + end +end diff --git a/app/models/contact.rb b/app/models/contact.rb index 9a4bf7bbd..114d0bb8f 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -29,7 +29,7 @@ class Contact < ActiveRecord::Base uniqueness: { message: :epp_id_taken }, format: { with: /\A[\w\-\:\.\_]*\z/i, message: :invalid }, length: { maximum: 100, message: :too_long_contact_code } - validate :ident_valid_format? + validate :val_ident_valid_format? validate :uniq_statuses? validate :validate_html @@ -58,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 @@ -81,6 +86,7 @@ class Contact < ActiveRecord::Base ] attr_accessor :deliver_emails + attr_accessor :domain_transfer # hack but solves problem faster # # STATUSES @@ -233,13 +239,18 @@ class Contact < ActiveRecord::Base name || '[no name]' end - def ident_valid_format? - case ident_type - when 'priv' - case ident_country_code - when 'EE' - code = Isikukood.new(ident) - errors.add(:ident, :invalid_EE_identity_format) unless code.valid? + def val_ident_valid_format? + case ident_country_code + when 'EE'.freeze + err_msg = "invalid_EE_identity_format#{"_update" if id}".to_sym + case ident_type + when 'priv'.freeze + errors.add(:ident, err_msg) unless Isikukood.new(ident).valid? + when 'org'.freeze + # !%w(1 7 8 9).freeze.include?(ident.first) || + if ident.size != 8 || !(ident =~/\A[0-9]{8}\z/) + errors.add(:ident, err_msg) + end end end end @@ -492,7 +503,8 @@ class Contact < ActiveRecord::Base end def update_related_whois_records - related_domain_descriptions.each{ |x, y| WhoisRecord.find_by(name: x).save} + ids = related_domain_descriptions.keys + RegenerateWhoisRecordJob.enqueue(ids, :name) if ids.present? 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/directo.rb b/app/models/directo.rb new file mode 100644 index 000000000..66fada5d1 --- /dev/null +++ b/app/models/directo.rb @@ -0,0 +1,60 @@ +class Directo < ActiveRecord::Base + belongs_to :item, polymorphic: true + + def self.send_receipts + new_trans = Invoice.where(invoice_type: "DEB", in_directo: false).where(cancelled_at: nil) + total = new_trans.count + counter = 0 + Rails.logger.info("[DIRECTO] Will try to send #{total} invoices") + + new_trans.find_in_batches(batch_size: 10).each do |group| + mappers = {} # need them as no direct connection between invoice + builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml| + xml.invoices { + group.each do |invoice| + + if invoice.account_activity.nil? || invoice.account_activity.bank_transaction.nil? || + invoice.account_activity.bank_transaction.sum.nil? || invoice.account_activity.bank_transaction.sum != invoice.sum_cache + Rails.logger.info("[DIRECTO] Invoice #{invoice.number} has been skipped") + next + end + counter += 1 + + num = invoice.number + mappers[num] = invoice + xml.invoice( + "SalesAgent" => Setting.directo_sales_agent, + "Number" => num, + "InvoiceDate" => invoice.created_at.strftime("%Y-%m-%dT%H:%M:%S"), + "PaymentTerm" => Setting.directo_receipt_payment_term, + "Currency" => invoice.currency, + "CustomerCode"=> invoice.buyer.try(:directo_handle) + ){ + xml.line( + "ProductID" => Setting.directo_receipt_product_name, + "Quantity" => 1, + "UnitPriceWoVAT" => ActionController::Base.helpers.number_with_precision(invoice.sum_cache/(1+invoice.vat_prc), precision: 2, separator: "."), + "ProductName" => invoice.description + ) + } + end + } + end + + data = builder.to_xml.gsub("\n",'') + response = RestClient::Request.execute(url: ENV['directo_invoice_url'], method: :post, payload: {put: "1", what: "invoice", xmldata: data}, verify_ssl: false).to_s + dump_result_to_db(mappers, response) + end + + STDOUT << "#{Time.zone.now.utc} - Directo receipts sending finished. #{counter} of #{total} are sent\n" + end + + def self.dump_result_to_db mappers, xml + Nokogiri::XML(xml).css("Result").each do |res| + obj = mappers[res.attributes["docid"].value.to_i] + obj.directo_records.create!(response: res.as_json.to_h) + obj.update_columns(in_directo: true) + Rails.logger.info("[DIRECTO] Invoice #{res.attributes["docid"].value} was pushed and return is #{res.as_json.to_h.inspect}") + end + end +end diff --git a/app/models/domain.rb b/app/models/domain.rb index a76de9e4a..5beb1e77b 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -93,7 +93,7 @@ class Domain < ActiveRecord::Base def update_reserved_domains return unless in_reserved_list? rd = ReservedDomain.by_domain(name).first - rd.names[name] = SecureRandom.hex + rd.password = SecureRandom.hex rd.save end @@ -203,6 +203,31 @@ class Domain < ActiveRecord::Base statuses.include? DomainStatus::SERVER_TECH_CHANGE_PROHIBITED end + def self.clean_expired_pendings + ActiveSupport::Deprecation.instance.deprecation_warning(DomainCron, __method__) + DomainCron.send(__method__) + end + + def self.start_expire_period + ActiveSupport::Deprecation.instance.deprecation_warning(DomainCron, __method__) + DomainCron.send(__method__) + end + + def self.start_redemption_grace_period + ActiveSupport::Deprecation.instance.deprecation_warning(DomainCron, __method__) + DomainCron.send(__method__) + end + + def self.start_delete_period + ActiveSupport::Deprecation.instance.deprecation_warning(DomainCron, __method__) + DomainCron.send(__method__) + end + + def self.destroy_delete_candidates + ActiveSupport::Deprecation.instance.deprecation_warning(DomainCron, __method__) + DomainCron.send(__method__) + end + class << self def convert_period_to_time(period, unit) return (period.to_i / 365).years if unit == 'd' @@ -220,126 +245,9 @@ class Domain < ActiveRecord::Base { admin_contacts: :registrar } ) end - def next_id self.connection.select_value("SELECT nextval('#{self.sequence_name}')") end - - # rubocop: disable Metrics/AbcSize - # rubocop: disable Metrics/CyclomaticComplexity - # rubocop: disable Metrics/PerceivedComplexity - def clean_expired_pendings - STDOUT << "#{Time.zone.now.utc} - Clean expired domain pendings\n" unless Rails.env.test? - - expire_at = Setting.expire_pending_confirmation.hours.ago - count = 0 - expired_pending_domains = Domain.where('registrant_verification_asked_at <= ?', expire_at) - expired_pending_domains.each do |domain| - unless domain.pending_update? || domain.pending_delete? || domain.pending_delete_confirmation? - msg = "#{Time.zone.now.utc} - ISSUE: DOMAIN #{domain.id}: #{domain.name} IS IN EXPIRED PENDING LIST, " \ - "but no pendingDelete/pendingUpdate state present!\n" - STDOUT << msg unless Rails.env.test? - next - end - count += 1 - if domain.pending_update? - DomainMailer.pending_update_expired_notification_for_new_registrant(domain.id).deliver - end - if domain.pending_delete? || domain.pending_delete_confirmation? - DomainMailer.pending_delete_expired_notification(domain.id, true).deliver - end - domain.clean_pendings! - unless Rails.env.test? - STDOUT << "#{Time.zone.now.utc} Domain.clean_expired_pendings: ##{domain.id} (#{domain.name})\n" - end - end - STDOUT << "#{Time.zone.now.utc} - Successfully cancelled #{count} domain pendings\n" unless Rails.env.test? - count - end - # rubocop: enable Metrics/PerceivedComplexity - # rubocop: enable Metrics/AbcSize - # rubocop: enable Metrics/CyclomaticComplexity - - # rubocop: disable Metrics/LineLength - def start_expire_period - STDOUT << "#{Time.zone.now.utc} - Expiring domains\n" unless Rails.env.test? - - domains = Domain.where('valid_to <= ?', Time.zone.now) - domains.each do |domain| - next unless domain.expirable? - domain.set_graceful_expired - DomainMailer.expiration_reminder(domain.id).deliver - STDOUT << "#{Time.zone.now.utc} Domain.start_expire_period: ##{domain.id} (#{domain.name}) #{domain.changes}\n" unless Rails.env.test? - domain.save - end - - STDOUT << "#{Time.zone.now.utc} - Successfully expired #{domains.count} domains\n" unless Rails.env.test? - end - - def start_redemption_grace_period - STDOUT << "#{Time.zone.now.utc} - Setting server_hold to domains\n" unless Rails.env.test? - - d = Domain.where('outzone_at <= ?', Time.zone.now) - d.each do |domain| - next unless domain.server_holdable? - domain.statuses << DomainStatus::SERVER_HOLD - STDOUT << "#{Time.zone.now.utc} Domain.start_redemption_grace_period: ##{domain.id} (#{domain.name}) #{domain.changes}\n" unless Rails.env.test? - domain.save - end - - STDOUT << "#{Time.zone.now.utc} - Successfully set server_hold to #{d.count} domains\n" unless Rails.env.test? - end - - def start_delete_period - STDOUT << "#{Time.zone.now.utc} - Setting delete_candidate to domains\n" unless Rails.env.test? - - d = Domain.where('delete_at <= ?', Time.zone.now) - d.each do |domain| - next unless domain.delete_candidateable? - domain.statuses << DomainStatus::DELETE_CANDIDATE - STDOUT << "#{Time.zone.now.utc} Domain.start_delete_period: ##{domain.id} (#{domain.name}) #{domain.changes}\n" unless Rails.env.test? - domain.save - end - - return if Rails.env.test? - STDOUT << "#{Time.zone.now.utc} - Successfully set delete_candidate to #{d.count} domains\n" - end - - # rubocop:disable Rails/FindEach - # rubocop:disable Metrics/AbcSize - def destroy_delete_candidates - STDOUT << "#{Time.zone.now.utc} - Destroying domains\n" unless Rails.env.test? - - c = 0 - Domain.where("statuses @> '{deleteCandidate}'::varchar[]").each do |x| - Whois::Record.where('domain_id = ?', x.id).try(':destroy') - destroy_with_message x - STDOUT << "#{Time.zone.now.utc} Domain.destroy_delete_candidates: by deleteCandidate ##{x.id} (#{x.name})\n" unless Rails.env.test? - - c += 1 - end - - Domain.where('force_delete_at <= ?', Time.zone.now).each do |x| - Whois::Record.where('domain_id = ?', x.id).try(':destroy') - 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 - end - - STDOUT << "#{Time.zone.now.utc} - Successfully destroyed #{c} domains\n" unless Rails.env.test? - end - # rubocop: enable Metrics/AbcSize - # rubocop:enable Rails/FindEach - # rubocop: enable Metrics/LineLength - def destroy_with_message(domain) - domain.destroy - bye_bye = domain.versions.last - domain.registrar.messages.create!( - body: "#{I18n.t(:domain_deleted)}: #{domain.name}", - attached_obj_id: bye_bye.id, - attached_obj_type: bye_bye.class.to_s # DomainVersion - ) - end end def name=(value) @@ -412,8 +320,7 @@ class Domain < ActiveRecord::Base end end - return false if statuses.include_any?(DomainStatus::DELETE_CANDIDATE, DomainStatus::SERVER_RENEW_PROHIBITED, - DomainStatus::CLIENT_RENEW_PROHIBITED, DomainStatus::PENDING_RENEW, + return false if statuses.include_any?(DomainStatus::DELETE_CANDIDATE, DomainStatus::PENDING_RENEW, DomainStatus::PENDING_TRANSFER, DomainStatus::PENDING_DELETE, DomainStatus::PENDING_UPDATE, DomainStatus::PENDING_DELETE_CONFIRMATION) true @@ -443,8 +350,26 @@ class Domain < ActiveRecord::Base save end + + # state change shouln't be + def clean_pendings_lowlevel + statuses.delete(DomainStatus::PENDING_DELETE_CONFIRMATION) + statuses.delete(DomainStatus::PENDING_UPDATE) + statuses.delete(DomainStatus::PENDING_DELETE) + + status_notes[DomainStatus::PENDING_UPDATE] = '' + status_notes[DomainStatus::PENDING_DELETE] = '' + + update_columns( + registrant_verification_token: nil, + registrant_verification_asked_at: nil, + pending_json: {}, + status_notes: status_notes, + statuses: statuses.presence || [DomainStatus::OK] + ) + end + def pending_update! - old_registrant_id = registrant_id return true if pending_update? self.epp_pending_update = true # for epp @@ -456,8 +381,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 @@ -549,7 +474,7 @@ class Domain < ActiveRecord::Base def validate_nameserver_ips nameservers.to_a.reject(&:marked_for_destruction?).each do |ns| - next unless 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) @@ -579,7 +504,7 @@ class Domain < ActiveRecord::Base def name_in_wire_format res = '' - parts = name.split('.') + parts = name_puny.split('.') parts.each do |x| res += format('%02X', x.length) # length of label in hex res += x.each_byte.map { |b| format('%02X', b) }.join # label @@ -715,8 +640,12 @@ class Domain < ActiveRecord::Base case s when DomainStatus::PENDING_DELETE self.delete_at = nil - # Handle any other special remove cases? - # when DomainStatus::FORCE_DELETE unset_force_delete + when DomainStatus::SERVER_MANUAL_INZONE # removal causes server hold to set + self.outzone_at = Time.zone.now if self.force_delete_at.present? + when DomainStatus::DomainStatus::EXPIRED # removal causes server hold to set + self.outzone_at = self.valid_to + 15.day + when DomainStatus::DomainStatus::SERVER_HOLD # removal causes server hold to set + self.outzone_at = nil end end end @@ -823,5 +752,24 @@ 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 + + + def self.to_csv + CSV.generate do |csv| + csv << column_names + all.each do |domain| + csv << domain.attributes.values_at(*column_names) + end + end + end + + def self.pdf(html) + kit = PDFKit.new(html) + kit.to_pdf + end end # rubocop: enable Metrics/ClassLength diff --git a/app/models/domain_cron.rb b/app/models/domain_cron.rb new file mode 100644 index 000000000..74c09740e --- /dev/null +++ b/app/models/domain_cron.rb @@ -0,0 +1,122 @@ +class DomainCron + + def self.clean_expired_pendings + STDOUT << "#{Time.zone.now.utc} - Clean expired domain pendings\n" unless Rails.env.test? + + expire_at = Setting.expire_pending_confirmation.hours.ago + count = 0 + expired_pending_domains = Domain.where('registrant_verification_asked_at <= ?', expire_at) + expired_pending_domains.each do |domain| + unless domain.pending_update? || domain.pending_delete? || domain.pending_delete_confirmation? + msg = "#{Time.zone.now.utc} - ISSUE: DOMAIN #{domain.id}: #{domain.name} IS IN EXPIRED PENDING LIST, " \ + "but no pendingDelete/pendingUpdate state present!\n" + STDOUT << msg unless Rails.env.test? + next + end + count += 1 + if domain.pending_update? + DomainMailer.pending_update_expired_notification_for_new_registrant(domain.id).deliver + end + if domain.pending_delete? || domain.pending_delete_confirmation? + DomainMailer.pending_delete_expired_notification(domain.id, deliver_emails).deliver + end + domain.clean_pendings_lowlevel + unless Rails.env.test? + STDOUT << "#{Time.zone.now.utc} DomainCron.clean_expired_pendings: ##{domain.id} (#{domain.name})\n" + end + end + STDOUT << "#{Time.zone.now.utc} - Successfully cancelled #{count} domain pendings\n" unless Rails.env.test? + count + end + + def self.start_expire_period + STDOUT << "#{Time.zone.now.utc} - Expiring domains\n" unless Rails.env.test? + + domains = Domain.where('valid_to <= ?', Time.zone.now) + marked = 0 + real = 0 + domains.each do |domain| + next unless domain.expirable? + real += 1 + domain.set_graceful_expired + STDOUT << "#{Time.zone.now.utc} DomainCron.start_expire_period: ##{domain.id} (#{domain.name}) #{domain.changes}\n" unless Rails.env.test? + domain.save(validate: false) and marked += 1 + end + + STDOUT << "#{Time.zone.now.utc} - Successfully expired #{marked} of #{real} domains\n" unless Rails.env.test? + end + + def self.start_redemption_grace_period + STDOUT << "#{Time.zone.now.utc} - Setting server_hold to domains\n" unless Rails.env.test? + + d = Domain.where('outzone_at <= ?', Time.zone.now) + marked = 0 + real = 0 + d.each do |domain| + next unless domain.server_holdable? + real += 1 + domain.statuses << DomainStatus::SERVER_HOLD + STDOUT << "#{Time.zone.now.utc} DomainCron.start_redemption_grace_period: ##{domain.id} (#{domain.name}) #{domain.changes}\n" unless Rails.env.test? + domain.save(validate: false) and marked += 1 + end + + STDOUT << "#{Time.zone.now.utc} - Successfully set server_hold to #{marked} of #{real} domains\n" unless Rails.env.test? + marked + end + + def self.start_delete_period + begin + STDOUT << "#{Time.zone.now.utc} - Setting delete_candidate to domains\n" unless Rails.env.test? + + d = Domain.where('delete_at <= ?', Time.zone.now) + marked = 0 + real = 0 + d.each do |domain| + next unless domain.delete_candidateable? + real += 1 + domain.statuses << DomainStatus::DELETE_CANDIDATE + STDOUT << "#{Time.zone.now.utc} DomainCron.start_delete_period: ##{domain.id} (#{domain.name}) #{domain.changes}\n" unless Rails.env.test? + domain.save(validate: false) and marked += 1 + end + ensure # the operator should see what was accomplished + STDOUT << "#{Time.zone.now.utc} - Finished setting delete_candidate - #{marked} out of #{real} successfully set\n" unless Rails.env.test? + end + marked + end + + def self.destroy_delete_candidates + STDOUT << "#{Time.zone.now.utc} - Destroying domains\n" unless Rails.env.test? + + c = 0 + Domain.where("statuses @> '{deleteCandidate}'::varchar[]").each do |x| + 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? + + c += 1 + end + + Domain.where('force_delete_at <= ?', Time.zone.now).each do |x| + WhoisRecord.where(domain_id: x.id).destroy_all + destroy_with_message x + STDOUT << "#{Time.zone.now.utc} DomainCron.destroy_delete_candidates: by force delete time ##{x.id} (#{x.name})\n" unless Rails.env.test? + c += 1 + end + + STDOUT << "#{Time.zone.now.utc} - Successfully destroyed #{c} domains\n" unless Rails.env.test? + end + + # rubocop: enable Metrics/AbcSize + # rubocop:enable Rails/FindEach + # rubocop: enable Metrics/LineLength + def self.destroy_with_message(domain) + domain.destroy + bye_bye = domain.versions.last + domain.registrar.messages.create!( + body: "#{I18n.t(:domain_deleted)}: #{domain.name}", + attached_obj_id: bye_bye.id, + attached_obj_type: bye_bye.class.to_s # DomainVersion + ) + end + +end 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/contact.rb b/app/models/epp/contact.rb index ec5673b06..54806b88d 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -123,6 +123,7 @@ class Epp::Contact < Contact [:email, :invalid], [:ident, :invalid], [:ident, :invalid_EE_identity_format], + [:ident, :invalid_EE_identity_format_update], [:ident, :invalid_birthday_format], [:ident, :invalid_country_code], [:ident_type, :missing], @@ -160,20 +161,20 @@ class Epp::Contact < Contact self.ident_updated_at ||= Time.zone.now # not in use ident_frame = frame.css('ident').first - if ident_frame && ident_attr_valid?(ident_frame) && ident_country_code.blank? && ident_type.in?(%w(org priv).freeze) - at.merge!(ident_country_code: ident_frame.attr('cc')) + if ident_frame && ident_attr_valid?(ident_frame) + org_priv = %w(org priv).freeze + if ident_country_code.blank? && org_priv.include?(ident_type) && org_priv.include?(ident_frame.attr('type')) + at.merge!(ident_country_code: ident_frame.attr('cc'), ident_type: ident_frame.attr('type')) + elsif ident_type == "birthday" && !ident[/\A\d{4}-\d{2}-\d{2}\z/] && (Date.parse(ident) rescue false) + at.merge!(ident: ident_frame.text) + at.merge!(ident_country_code: ident_frame.attr('cc')) if ident_frame.attr('cc').present? + elsif ident_type.blank? && ident_country_code.blank? + at.merge!(ident_type: ident_frame.attr('type')) + at.merge!(ident_country_code: ident_frame.attr('cc')) if ident_frame.attr('cc').present? + else + throw :epp_error, {code: '2306', msg: I18n.t(:ident_update_error)} + end end - - # Deprecated - # if ident_updated_at.present? - # throw :epp_error, { - # code: '2306', - # msg: I18n.t(:ident_update_error) - # } - # else - # at.merge!(self.class.ident_attrs(frame.css('ident').first)) - # self.ident_updated_at = Time.zone.now - # end end super(at) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 12eeaf70d..c7b5cf8ed 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 || is_renewal 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? } @@ -486,6 +488,15 @@ class Epp::Domain < Domain # at[:statuses] += at_add[:domain_statuses_attributes] + if registrant_id && registrant.code == frame.css('registrant') + + throw :epp_error, { + code: '2305', + msg: I18n.t(:contact_already_associated_with_the_domain) + } + + end + if errors.empty? && verify && Setting.request_confrimation_on_registrant_change_enabled && frame.css('registrant').present? && @@ -500,20 +511,22 @@ 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']) - statuses.delete(DomainStatus::PENDING_UPDATE) - yield(self) if block_given? # need to skip statuses check here - self.save + self.deliver_emails = true # turn on email delivery + self.statuses.delete(DomainStatus::PENDING_UPDATE) ::PaperTrail.whodunnit = user.id_role_username # updator str should be the request originator not the approval user + + send_mail :registrant_updated_notification_for_old_registrant 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 + WhoisRecord.find_by(domain_id: id).save # need to reload model + + save! # for notification if everything fails true end @@ -586,6 +599,7 @@ class Epp::Domain < Domain statuses.delete(DomainStatus::SERVER_HOLD) statuses.delete(DomainStatus::EXPIRED) + statuses.delete(DomainStatus::SERVER_UPDATE_PROHIBITED) save end @@ -594,6 +608,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? @@ -621,6 +637,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..425202a4c 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -2,14 +2,27 @@ class Invoice < ActiveRecord::Base include Versions belongs_to :seller, class_name: 'Registrar' belongs_to :buyer, class_name: 'Registrar' + has_one :account_activity has_many :invoice_items - has_one :account_activity + has_many :directo_records, as: :item, class_name: 'Directo' accepts_nested_attributes_for :invoice_items scope :unbinded, lambda { where('id NOT IN (SELECT invoice_id FROM account_activities where invoice_id IS NOT NULL)') } + scope :all_columns, ->{select("invoices.*")} + scope :sort_due_date_column, ->{all_columns.select("CASE WHEN invoices.cancelled_at is not null THEN + (invoices.cancelled_at + interval '100 year') ELSE + invoices.due_date END AS sort_due_date")} + scope :sort_by_sort_due_date_asc, ->{sort_due_date_column.order("sort_due_date ASC")} + scope :sort_by_sort_due_date_desc, ->{sort_due_date_column.order("sort_due_date DESC")} + scope :sort_receipt_date_column, ->{all_columns.includes(:account_activity).references(:account_activity).select(%Q{ + CASE WHEN account_activities.created_at is not null THEN account_activities.created_at + WHEN invoices.cancelled_at is not null THEN invoices.cancelled_at + interval '100 year' + ELSE NULL END AS sort_receipt_date })} + scope :sort_by_sort_receipt_date_asc, ->{sort_receipt_date_column.order("sort_receipt_date ASC")} + scope :sort_by_sort_receipt_date_desc, ->{sort_receipt_date_column.order("sort_receipt_date DESC")} attr_accessor :billing_email validates :billing_email, email_format: { message: :invalid }, allow_blank: true @@ -17,7 +30,10 @@ 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 + + before_save :check_vat + def set_invoice_number last_no = Invoice.order(number: :desc).where('number IS NOT NULL').limit(1).pluck(:number).first @@ -34,6 +50,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 @@ -90,6 +112,10 @@ class Invoice < ActiveRecord::Base kit.to_pdf end + def description + "Order nr. #{number}" + end + def pdf_name "invoice-#{number}.pdf" end 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_user.rb b/app/models/registrant_user.rb index 9a69e8acb..413ff1202 100644 --- a/app/models/registrant_user.rb +++ b/app/models/registrant_user.rb @@ -1,4 +1,5 @@ class RegistrantUser < User + ACCEPTED_ISSUER = 'AS Sertifitseerimiskeskus' attr_accessor :idc_data def ability @@ -6,6 +7,19 @@ class RegistrantUser < User end delegate :can?, :cannot?, to: :ability + def ident + registrant_ident.to_s.split("-").last + end + + def domains + ident_cc, ident = registrant_ident.to_s.split '-' + Domain.includes(:registrar, :registrant).where(contacts: { + ident_type: 'priv', + ident: ident, #identity_code, + ident_country_code: ident_cc #country_code + }) + end + def to_s username end @@ -13,11 +27,9 @@ class RegistrantUser < User class << self def find_or_create_by_idc_data(idc_data, issuer_organization) return false if idc_data.blank? - return false if issuer_organization != 'AS Sertifitseerimiskeskus' + return false if issuer_organization != ACCEPTED_ISSUER idc_data.force_encoding('UTF-8') - logger.error(idc_data) - logger.error(idc_data.encoding) identity_code = idc_data.scan(/serialNumber=(\d+)/).flatten.first country = idc_data.scan(/^\/C=(.{2})/).flatten.first first_name = idc_data.scan(%r{/GN=(.+)/serialNumber}).flatten.first diff --git a/app/models/registrant_verification.rb b/app/models/registrant_verification.rb index d0c015ecb..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 @@ -23,7 +22,7 @@ class RegistrantVerification < ActiveRecord::Base def domain_registrant_change_reject! self.action_type = DOMAIN_REGISTRANT_CHANGE self.action = REJECTED - DomainUpdateConfirmJob.enqueue domain.id, REJECTED if save + DomainUpdateConfirmJob.run domain.id, REJECTED if save end def domain_registrant_delete_confirm! diff --git a/app/models/reserved_domain.rb b/app/models/reserved_domain.rb index 09d72ec17..8b2cb49e6 100644 --- a/app/models/reserved_domain.rb +++ b/app/models/reserved_domain.rb @@ -1,25 +1,75 @@ class ReservedDomain < ActiveRecord::Base include Versions # version/reserved_domain_version.rb before_save :fill_empty_passwords + before_save :generate_data + before_destroy :remove_data + validates :name, domain_name: true, uniqueness: true + + - def fill_empty_passwords - return unless names - names.each { |k, v| names[k] = SecureRandom.hex if v.blank? } - end class << self def pw_for(domain_name) - name_in_unicode = SimpleIDN.to_ascii(domain_name) - by_domain(domain_name).select("names -> '#{domain_name}' AS pw").first.try(:pw) || - by_domain(name_in_unicode).select("names -> '#{name_in_unicode}' AS pw").first.try(:pw) + name_in_ascii = SimpleIDN.to_ascii(domain_name) + by_domain(domain_name).first.try(:password) || by_domain(name_in_ascii).first.try(:password) end def by_domain name - where("names ? '#{name}'") + where(name: name) end def any_of_domains names - where("names ?| ARRAY['#{names.join("','")}']") + where(name: names) end end + + + def fill_empty_passwords + + if self.password.empty? + + self.password = SecureRandom.hex + + end + end + + def name= val + super SimpleIDN.to_unicode(val) + end + + def generate_data + return if Domain.where(name: name).any? + + @json = generate_json + @body = generate_body + update_whois_server + end + + alias_method :update_whois_record, :generate_data + + def update_whois_server + wr = Whois::Record.find_or_initialize_by(name: name) + wr.body = @body + wr.json = @json + wr.save + end + + def generate_body + template = Rails.root.join("app/views/for_models/whois_other.erb".freeze) + ERB.new(template.read, nil, "-").result(binding) + end + + def generate_json + h = HashWithIndifferentAccess.new + h[:name] = self.name + h[:status] = 'Reserved' + h + end + + def remove_data + return if Domain.where(name: name).any? + + Whois::Record.where(name: name).delete_all + end + end diff --git a/app/models/soap/arireg.rb b/app/models/soap/arireg.rb new file mode 100644 index 000000000..422a72dd9 --- /dev/null +++ b/app/models/soap/arireg.rb @@ -0,0 +1,219 @@ +# coding: utf-8 +require 'savon' +=begin + +Estonian Business registry provides information about registered companies via xml (SOAP over HTTPS). + +Note: + The SSL endpoint certificate is self signed. + +Documentation: + http://www.rik.ee/et/e-ariregister/xml-teenus + Specifications are in Eng and Est + User contract required + +Testing: + https://demo-ariregxml.rik.ee:447/testariport/?wsdl + http://demo-ariregxml.rik.ee:81 + https://demo-ariregxml.rik.ee:447 + +Live service: + https://ariregxml.rik.ee/ariport/?wsdl + https://ariregxml.rik.ee/ + +Implements Soap::Arireg # associated_businesses + 8. arireg.paringesindus_v4 + Rights of representation of all persons related to the company (newer) + http://www2.rik.ee/schemas/xtee/arireg/live/paringesindus_v4.xsd + expects personal id code, to fetch list of registered business id codes + returning {ident: person, ident_country_code: ... associated_businesses: [...id_codes...]} + +=end + +# do some SSL set up? +# ssl_version +# ssl_verify_mode +# ssl_cert_key_file +# ssl_cert_key +# ssl_cert_key_password +# ssl_cert_file +# ssl_cert +# ssl_ca_cert_file +# ssl_ca_cert + +module Soap + + class Arireg + + class NotAvailableError < StandardError + attr_accessor :json + def initialize(params) + params[:message] = "#{I18n.t(:business_registry_service_not_available)}" unless params.key? :message + @json = params + + super(params) + end + end + + class << self + attr_accessor :wsdl, :host, :username, :password + end + + def initialize + if self.class.username.nil? + if Rails.application.secrets.key?(:arireg) + arireg = Rails.application.secrets[:arireg].with_indifferent_access + self.class.username = arireg[:username] + self.class.password = arireg[:password] + if self.class.wsdl.nil? # no override of config/environments/* ? + self.class.wsdl = arireg[:wsdl] + self.class.host = arireg[:host] + end + else + self.class.username = ENV['arireg_username'] + self.class.password = ENV['arireg_password'] + end + end + if self.class.wsdl.nil? + self.class.wsdl = ENV['arireg_wsdl'] + self.class.host = ENV['arireg_host'] + end + + # note Savon has error if https w/non-standard port, + # use non-standard force to pre-set endpoint + @client = Savon.client(wsdl: self.class.wsdl, + host: self.class.host, + endpoint: "#{self.class.host}/cgi-bin/consumer_proxy") + @session = nil + end + + # retrieve business id codes for business that a person has a legal role + def associated_businesses(ident, ident_cc = 'EST') + begin + msg = { + 'fyysilise_isiku_kood' => ident, + 'fyysilise_isiku_koodi_riik' => country_code_3(ident_cc) + } + Rails.logger.info "[Ariregister] Request sent with data: #{msg.inspect}" + + response = @client.call :paringesindus_v4, message: body(msg) + content = extract response, :paringesindus_v4_response + Rails.logger.info "[Ariregister] Got response with data: #{content.inspect}" + + if content.present? && content[:ettevotjad].key?(:item) + business_ident = items(content, :ettevotjad).map{|item| item[:ariregistri_kood]} + else + business_ident = [] + end + + { + ident: ident, + ident_country_code: ident_cc, + # ident_type: 'priv', + retrieved_on: Time.now, + associated_businesses: business_ident + } + rescue Savon::SOAPFault => fault + Rails.logger.error "[Ariregister] #{fault} Äriregister arireg #{self.class.username} at #{self.class.host }" + raise NotAvailableError.new(exception: fault) + rescue HTTPI::SSLError => ssl_error + Rails.logger.error "[Ariregister] #{ssl_error} at #{self.class.host}" + raise NotAvailableError.new(exception: ssl_error) + rescue SocketError => sock + Rails.logger.error "[Ariregister] #{sock}" + raise NotAvailableError.new(exception: sock) + end + end + + def debug + @client.globals.log_level :debug + @client.globals.log true + @client.globals.pretty_print_xml true + @debug = true + @client + end + + private + + # add required elements to request + def body(args) + if @session.nil? + args['ariregister_kasutajanimi'] = self.class.username + args['ariregister_parool'] = self.class.password + else + args['ariregister_sessioon'] = @session + end + {keha: args} + end + + # TLA --- three letter acronym required not two letter acronym, transform + def country_code_3(code) + if code.length == 2 + code = CC2X3[code] + raise NotAvailableError.new(message: 'Unrecognized Country') if code.nil? + end + code + end + + def extract(response, element) + # response envelope body has again header/body under element; header is user and password returned + response.hash[:envelope][:body][element][:keha] + end + + def items(content, parent) + items = content[parent][:item] + items.is_a?(Array) ? items : [items] + end + + CC2X3 = {"AF"=>"AFG", "AX"=>"ALA", "AL"=>"ALB", "DZ"=>"DZA", "AS"=>"ASM", + "AD"=>"AND", "AO"=>"AGO", "AI"=>"AIA", "AQ"=>"ATA", "AG"=>"ATG", + "AR"=>"ARG", "AM"=>"ARM", "AW"=>"ABW", "AU"=>"AUS", "AT"=>"AUT", + "AZ"=>"AZE", "BS"=>"BHS", "BH"=>"BHR", "BD"=>"BGD", "BB"=>"BRB", + "BY"=>"BLR", "BE"=>"BEL", "BZ"=>"BLZ", "BJ"=>"BEN", "BM"=>"BMU", + "BT"=>"BTN", "BO"=>"BOL", "BQ"=>"BES", "BA"=>"BIH", "BW"=>"BWA", + "BV"=>"BVT", "BR"=>"BRA", "IO"=>"IOT", "BN"=>"BRN", "BG"=>"BGR", + "BF"=>"BFA", "BI"=>"BDI", "CV"=>"CPV", "KH"=>"KHM", "CM"=>"CMR", + "CA"=>"CAN", "KY"=>"CYM", "CF"=>"CAF", "TD"=>"TCD", "CL"=>"CHL", + "CN"=>"CHN", "CX"=>"CXR", "CC"=>"CCK", "CO"=>"COL", "KM"=>"COM", + "CD"=>"COD", "CG"=>"COG", "CK"=>"COK", "CR"=>"CRI", "CI"=>"CIV", + "HR"=>"HRV", "CU"=>"CUB", "CW"=>"CUW", "CY"=>"CYP", "CZ"=>"CZE", + "DK"=>"DNK", "DJ"=>"DJI", "DM"=>"DMA", "DO"=>"DOM", "EC"=>"ECU", + "EG"=>"EGY", "SV"=>"SLV", "GQ"=>"GNQ", "ER"=>"ERI", "EE"=>"EST", + "ET"=>"ETH", "FK"=>"FLK", "FO"=>"FRO", "FJ"=>"FJI", "FI"=>"FIN", + "FR"=>"FRA", "GF"=>"GUF", "PF"=>"PYF", "TF"=>"ATF", "GA"=>"GAB", + "GM"=>"GMB", "GE"=>"GEO", "DE"=>"DEU", "GH"=>"GHA", "GI"=>"GIB", + "GR"=>"GRC", "GL"=>"GRL", "GD"=>"GRD", "GP"=>"GLP", "GU"=>"GUM", + "GT"=>"GTM", "GG"=>"GGY", "GN"=>"GIN", "GW"=>"GNB", "GY"=>"GUY", + "HT"=>"HTI", "HM"=>"HMD", "VA"=>"VAT", "HN"=>"HND", "HK"=>"HKG", + "HU"=>"HUN", "IS"=>"ISL", "IN"=>"IND", "ID"=>"IDN", "IR"=>"IRN", + "IQ"=>"IRQ", "IE"=>"IRL", "IM"=>"IMN", "IL"=>"ISR", "IT"=>"ITA", + "JM"=>"JAM", "JP"=>"JPN", "JE"=>"JEY", "JO"=>"JOR", "KZ"=>"KAZ", + "KE"=>"KEN", "KI"=>"KIR", "KP"=>"PRK", "KR"=>"KOR", "KW"=>"KWT", + "KG"=>"KGZ", "LA"=>"LAO", "LV"=>"LVA", "LB"=>"LBN", "LS"=>"LSO", + "LR"=>"LBR", "LY"=>"LBY", "LI"=>"LIE", "LT"=>"LTU", "LU"=>"LUX", + "MO"=>"MAC", "MK"=>"MKD", "MG"=>"MDG", "MW"=>"MWI", "MY"=>"MYS", + "MV"=>"MDV", "ML"=>"MLI", "MT"=>"MLT", "MH"=>"MHL", "MQ"=>"MTQ", + "MR"=>"MRT", "MU"=>"MUS", "YT"=>"MYT", "MX"=>"MEX", "FM"=>"FSM", + "MD"=>"MDA", "MC"=>"MCO", "MN"=>"MNG", "ME"=>"MNE", "MS"=>"MSR", + "MA"=>"MAR", "MZ"=>"MOZ", "MM"=>"MMR", "NA"=>"NAM", "NR"=>"NRU", + "NP"=>"NPL", "NL"=>"NLD", "NC"=>"NCL", "NZ"=>"NZL", "NI"=>"NIC", + "NE"=>"NER", "NG"=>"NGA", "NU"=>"NIU", "NF"=>"NFK", "MP"=>"MNP", + "NO"=>"NOR", "OM"=>"OMN", "PK"=>"PAK", "PW"=>"PLW", "PS"=>"PSE", + "PA"=>"PAN", "PG"=>"PNG", "PY"=>"PRY", "PE"=>"PER", "PH"=>"PHL", + "PN"=>"PCN", "PL"=>"POL", "PT"=>"PRT", "PR"=>"PRI", "QA"=>"QAT", + "RE"=>"REU", "RO"=>"ROU", "RU"=>"RUS", "RW"=>"RWA", "BL"=>"BLM", + "SH"=>"SHN", "KN"=>"KNA", "LC"=>"LCA", "MF"=>"MAF", "PM"=>"SPM", + "VC"=>"VCT", "WS"=>"WSM", "SM"=>"SMR", "ST"=>"STP", "SA"=>"SAU", + "SN"=>"SEN", "RS"=>"SRB", "SC"=>"SYC", "SL"=>"SLE", "SG"=>"SGP", + "SX"=>"SXM", "SK"=>"SVK", "SI"=>"SVN", "SB"=>"SLB", "SO"=>"SOM", + "ZA"=>"ZAF", "GS"=>"SGS", "SS"=>"SSD", "ES"=>"ESP", "LK"=>"LKA", + "SD"=>"SDN", "SR"=>"SUR", "SJ"=>"SJM", "SZ"=>"SWZ", "SE"=>"SWE", + "CH"=>"CHE", "SY"=>"SYR", "TW"=>"TWN", "TJ"=>"TJK", "TZ"=>"TZA", + "TH"=>"THA", "TL"=>"TLS", "TG"=>"TGO", "TK"=>"TKL", "TO"=>"TON", + "TT"=>"TTO", "TN"=>"TUN", "TR"=>"TUR", "TM"=>"TKM", "TC"=>"TCA", + "TV"=>"TUV", "UG"=>"UGA", "UA"=>"UKR", "AE"=>"ARE", "GB"=>"GBR", + "UM"=>"UMI", "US"=>"USA", "UY"=>"URY", "UZ"=>"UZB", "VU"=>"VUT", + "VE"=>"VEN", "VN"=>"VNM", "VG"=>"VGB", "VI"=>"VIR", "WF"=>"WLF", + "EH"=>"ESH", "YE"=>"YEM", "ZM"=>"ZMB", "ZW"=>"ZWE"} + end +end diff --git a/app/models/whois_record.rb b/app/models/whois_record.rb index 21db2bdc0..c16e5ce73 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,11 +48,11 @@ 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 - h[:registrant_email] = domain.registrant.email + h[:email] = domain.registrant.email @disclosed << [:email, domain.registrant.email] h[:registrant_changed] = domain.registrant.updated_at.try(:to_s, :iso8601) @@ -102,7 +106,7 @@ class WhoisRecord < ActiveRecord::Base self.json = generated_json self.body = generated_body self.name = json['name'] - self.registrar_id = domain.registrar_id # for faster registrar updates + self.registrar_id = domain.registrar_id if domain # for faster registrar updates end def update_whois_server @@ -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/validators/domain_name_validator.rb b/app/validators/domain_name_validator.rb index e39437f2b..be83f0835 100644 --- a/app/validators/domain_name_validator.rb +++ b/app/validators/domain_name_validator.rb @@ -38,7 +38,7 @@ class DomainNameValidator < ActiveModel::EachValidator def validate_blocked(value) return true unless value - return false if BlockedDomain.where("names @> ?::varchar[]", "{#{value}}").count > 0 + return false if BlockedDomain.where(name: value).count > 0 ZonefileSetting.where(origin: value).count == 0 end end diff --git a/app/views/admin/account_activities/index.haml b/app/views/admin/account_activities/index.haml index 35e270dce..80ebba2f6 100644 --- a/app/views/admin/account_activities/index.haml +++ b/app/views/admin/account_activities/index.haml @@ -29,13 +29,24 @@ .form-group = f.label t(:receipt_date_until) = f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control datepicker', placeholder: t(:receipt_date_until), autocomplete: 'off' - .col-md-6{style: 'padding-top: 25px;'} + .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-default.search   %span.glyphicon.glyphicon-search   %button.btn.btn-default.js-reset-form = t(:clear_fields) +.row + .col-md-3 + .col-md-3 + .col-md-2 + .col-md-4{class: 'text-right'} + = t(:starting_balance) + " #{@sum.to_a.map(&:sum).sum.to_f} EUR" + %hr .row @@ -55,6 +66,7 @@ %th{class: 'col-xs-2'} = sort_link(@q, 'sum') %tbody + -total = @sum.to_a.map(&:sum).sum.to_f - @account_activities.each do |x| %tr %td= link_to(x.account.registrar.try(:code), admin_registrar_path(x.account.registrar)) @@ -63,7 +75,15 @@ %td= l(x.created_at) - c = x.sum > 0.0 ? 'text-success' : 'text-danger' - s = x.sum > 0.0 ? "+#{x.sum} #{x.currency}" : "#{x.sum} #{x.currency}" + -total += x.sum %td{class: c}= s + - if @account_activities.count > 0 + %tr + %td + %td + %td + %td{class: 'text-right'}= t(:total) + %td{class: total > 0 ? 'text-success' : 'text-danger'}= total > 0 ? "+#{total} EUR" : "#{total} EUR" .row .col-md-12 = paginate @account_activities diff --git a/app/views/admin/blocked_domains/_form.haml b/app/views/admin/blocked_domains/_form.haml new file mode 100644 index 000000000..996d52843 --- /dev/null +++ b/app/views/admin/blocked_domains/_form.haml @@ -0,0 +1,17 @@ += form_for([:admin, @domain], html: {class: 'form-horizontal'}) do |f| + = render 'shared/full_errors', object: @domain + + .row + .col-md-8 + .panel.panel-default + .panel-heading.clearfix + .pull-left= t(:general) + .panel-body + .form-group + .col-md-4.control-label + = f.label :name + .col-md-7 + = f.text_field(:name, class: 'form-control') + .row + .col-md-8.text-right + = button_tag(t(:save), class: 'btn btn-primary') diff --git a/app/views/admin/blocked_domains/edit.haml b/app/views/admin/blocked_domains/edit.haml new file mode 100644 index 000000000..51d77f0cc --- /dev/null +++ b/app/views/admin/blocked_domains/edit.haml @@ -0,0 +1,3 @@ += render 'shared/title', name: t(:edit_pw) + += render 'form' diff --git a/app/views/admin/blocked_domains/index.haml b/app/views/admin/blocked_domains/index.haml index bd5660193..5f6ac69d0 100644 --- a/app/views/admin/blocked_domains/index.haml +++ b/app/views/admin/blocked_domains/index.haml @@ -1,10 +1,68 @@ +- content_for :actions do + = link_to(t(:new), new_admin_blocked_domain_path, class: 'btn btn-primary') = render 'shared/title', name: t(:blocked_domains) -= form_tag([:admin, :blocked_domains]) do |f| - .row - .col-md-12 - = text_area_tag :blocked_domains, @blocked_domains, class: 'form-control', rows: 30 - %hr - .row - .col-md-12.text-right - %button.btn.btn-warning=t(:save) +.row + .col-md-12 + = search_form_for [:admin, @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(: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) + .row + .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) +%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') + %th{class: 'col-xs-2'} + = sort_link(@q, 'created_at', t(:created_at)) + %th{class: 'col-xs-2'} + = sort_link(@q, 'updated_at', t(:updated_at)) + %th{class: 'col-xs-1'} + = t(:actions) + %tbody + - @domains.each do |x| + %tr + %td= x.name + %td= l(x.created_at, format: :short) + %td= l(x.updated_at, format: :short) + %td + %div{class: 'text-center'} + = link_to(t(:delete), delete_admin_blocked_domain_path(id: x.id), + data: { confirm: t(:are_you_sure) }, class: 'btn btn-danger btn-xs') +.row + .col-md-6 + = paginate @domains + .col-md-6.text-right + .pagination + = t(:result_count, count: @domains.total_count) + +:coffee + $(".js-reset-form").on "click", (e) -> + e.preventDefault(); + window.location = "#{admin_blocked_domains_path}" diff --git a/app/views/admin/blocked_domains/new.haml b/app/views/admin/blocked_domains/new.haml new file mode 100644 index 000000000..4461eea40 --- /dev/null +++ b/app/views/admin/blocked_domains/new.haml @@ -0,0 +1,3 @@ += render 'shared/title', name: t(:add_blocked_domain) + += render 'form' diff --git a/app/views/admin/contacts/index.haml b/app/views/admin/contacts/index.haml index b8e7850e6..715b87eb6 100644 --- a/app/views/admin/contacts/index.haml +++ b/app/views/admin/contacts/index.haml @@ -29,15 +29,10 @@ .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 + .col-md-6 .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' } + = select_tag '[q][domain_contacts_type_in]', options_for_select([['admin', 'AdminDomainContact'], ['tech', 'TechDomainContact'], ['registrant', 'registrant']], params[:q][:domain_contacts_type_in]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' } .row .col-md-3 .form-group 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/domain_versions/_version.haml b/app/views/admin/domain_versions/_version.haml index fd449b4b0..321e9abda 100644 --- a/app/views/admin/domain_versions/_version.haml +++ b/app/views/admin/domain_versions/_version.haml @@ -55,43 +55,47 @@ = "#{l(domain.valid_to, format: :date)}" %td - - registrant.each do |r| - %p - = r[:name] - = r[:phone] - = r[:email] - %p - = r[:code] + - if registrant + - registrant.each do |r| + %p + = r[:name] + = r[:phone] + = r[:email] + %p + = r[:code] %td - - admin_contacts.each do |ac| - %p - = ac[:name] - = ac[:phone] - = ac[:email] - %p - = ac[:code] + - if admin_contacts + - admin_contacts.each do |ac| + %p + = ac[:name] + = ac[:phone] + = ac[:email] + %p + = ac[:code] %td - - tech_contacts.each do |tc| - %p - = tc[:name] - = tc[:phone] - = tc[:email] - %p - = tc[:code] + - if tech_contacts + - tech_contacts.each do |tc| + %p + = tc[:name] + = tc[:phone] + = tc[:email] + %p + = tc[:code] %td %p - - nameservers.each do |ns| - = ns[:hostname] - %br - = ns[:ipv4] - = ns[:ipv6] + - if nameservers + - nameservers.each do |ns| + = ns[:hostname] + %br + = ns[:ipv4] + = ns[:ipv6] %td %p - = domain.registrar.name + = domain.registrar.name if domain.registrar - if domain.pending_json.present? %tr.js-pending{ style: 'display: none;' } 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/invoices/index.haml b/app/views/admin/invoices/index.haml index 75b6285a4..4b34dba94 100644 --- a/app/views/admin/invoices/index.haml +++ b/app/views/admin/invoices/index.haml @@ -8,13 +8,13 @@ %thead %tr %th{class: 'col-xs-3'} - = sort_link(@q, 'invoice') + = sort_link(@q, :number) %th{class: 'col-xs-3'} - = sort_link(@q, 'buyer') + = sort_link(@q, :buyer_name, "Buyer") %th{class: 'col-xs-3'} - = sort_link(@q, 'due_date') + = sort_link(@q, :sort_due_date, "Due date") %th{class: 'col-xs-3'} - = sort_link(@q, 'receipt_date') + = sort_link(@q, :sort_receipt_date, "Receipt date") %tbody - @invoices.each do |x| %tr 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/admin/registrars/index.haml b/app/views/admin/registrars/index.haml index a2604dbec..8ba45d205 100644 --- a/app/views/admin/registrars/index.haml +++ b/app/views/admin/registrars/index.haml @@ -8,15 +8,18 @@ %table.table.table-hover.table-bordered.table-condensed %thead %tr - %th{class: 'col-xs-6'} + %th{class: 'col-xs-4'} = sort_link(@q, 'name') - %th{class: 'col-xs-6'} + %th{class: 'col-xs-4'} = sort_link(@q, 'reg_no', t(:reg_no)) + %th{class: 'col-xs-4'} + = t(:credit_balance) %tbody - @registrars.each do |x| %tr %td= link_to(x, [:admin, x]) %td= x.reg_no + %td= "#{x.balance}" .row .col-md-12 = paginate @registrars diff --git a/app/views/admin/registrars/show.haml b/app/views/admin/registrars/show.haml index e3966583f..35938c0c6 100644 --- a/app/views/admin/registrars/show.haml +++ b/app/views/admin/registrars/show.haml @@ -32,6 +32,9 @@ %dt= t(:id) %dd= @registrar.code + %dt= t(:credit_balance) + %dd= @registrar.balance + .col-md-6 .panel.panel-default .panel-heading diff --git a/app/views/admin/reserved_domains/_form.haml b/app/views/admin/reserved_domains/_form.haml new file mode 100644 index 000000000..ec7492659 --- /dev/null +++ b/app/views/admin/reserved_domains/_form.haml @@ -0,0 +1,22 @@ += form_for([:admin, @domain], html: {class: 'form-horizontal'}) do |f| + = render 'shared/full_errors', object: @domain + + .row + .col-md-8 + .panel.panel-default + .panel-heading.clearfix + .pull-left= t(:general) + .panel-body + .form-group + .col-md-4.control-label + = f.label :name + .col-md-7 + = f.text_field(:name, class: 'form-control', disabled: !f.object.new_record?) + .form-group + .col-md-4.control-label + = f.label :password + .col-md-7 + = f.text_field(:password, placeholder: t(:optional), class: 'form-control') + .row + .col-md-8.text-right + = button_tag(t(:save), class: 'btn btn-primary') diff --git a/app/views/admin/reserved_domains/edit.haml b/app/views/admin/reserved_domains/edit.haml new file mode 100644 index 000000000..51d77f0cc --- /dev/null +++ b/app/views/admin/reserved_domains/edit.haml @@ -0,0 +1,3 @@ += render 'shared/title', name: t(:edit_pw) + += render 'form' diff --git a/app/views/admin/reserved_domains/index.haml b/app/views/admin/reserved_domains/index.haml index 15840ff93..06825b624 100644 --- a/app/views/admin/reserved_domains/index.haml +++ b/app/views/admin/reserved_domains/index.haml @@ -1,14 +1,72 @@ - content_for :actions do - = link_to('#', class: 'btn btn-default', "data-container": "body", "data-title": t('list_format_is_in_yaml'), "data-content": "domain.ee: authinfopw
seconddomain.ee:
thirddomain.ee: authinfo3

#{t('if_auth_info_is_left_empty_it_will_be_auto_generated')}
#{t('each_domain_name_must_end_with_colon_sign')}", "data-placement": "left", "data-toggle": "popover", "data-html" => "true") do - %span.glyphicon.glyphicon-info-sign{"aria-hidden" => "true"} - + = link_to(t(:new), new_admin_reserved_domain_path, class: 'btn btn-primary') = render 'shared/title', name: t(:reserved_domains) -= form_tag([:admin, :reserved_domains]) do |f| - .row - .col-md-12 - = text_area_tag :reserved_domains, @reserved_domains, class: 'form-control', rows: 30 - %hr - .row - .col-md-12.text-right - %button.btn.btn-warning=t(:save) +.row + .col-md-12 + = search_form_for [:admin, @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(: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) + .row + .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) +%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') + %th{class: 'col-xs-2'} + = sort_link(@q, 'password') + %th{class: 'col-xs-2'} + = sort_link(@q, 'created_at', t(:created_at)) + %th{class: 'col-xs-2'} + = sort_link(@q, 'updated_at', t(:updated_at)) + %th{class: 'col-xs-2'} + = t(:actions) + %tbody + - @domains.each do |x| + %tr + %td= x.name + %td= x.password + %td= l(x.created_at, format: :short) + %td= l(x.updated_at, format: :short) + %td + = link_to(t(:edit_pw), edit_admin_reserved_domain_path(id: x.id), + class: 'btn btn-primary btn-xs') + = link_to(t(:delete), delete_admin_reserved_domain_path(id: x.id), + data: { confirm: t(:are_you_sure) }, class: 'btn btn-danger btn-xs') +.row + .col-md-6 + = paginate @domains + .col-md-6.text-right + .pagination + = t(:result_count, count: @domains.total_count) + +:coffee + $(".js-reset-form").on "click", (e) -> + e.preventDefault(); + window.location = "#{admin_reserved_domains_path}" diff --git a/app/views/admin/reserved_domains/new.haml b/app/views/admin/reserved_domains/new.haml new file mode 100644 index 000000000..cd6e189f9 --- /dev/null +++ b/app/views/admin/reserved_domains/new.haml @@ -0,0 +1,3 @@ += render 'shared/title', name: t(:add_reserved_domain) + += render 'form' diff --git a/app/views/admin/settings/index.haml b/app/views/admin/settings/index.haml index ede30e979..863d197d0 100644 --- a/app/views/admin/settings/index.haml +++ b/app/views/admin/settings/index.haml @@ -36,6 +36,7 @@ = render 'setting_row', var: :days_to_renew_domain_before_expire = render 'setting_row', var: :expire_warning_period = render 'setting_row', var: :redemption_grace_period + = render 'setting_row', var: :expiration_reminder_mail .panel.panel-default .panel-heading.clearfix @@ -50,6 +51,7 @@ = render 'setting_row', var: :transfer_wait_time = render 'setting_row', var: :ds_digest_type = render 'setting_row', var: :client_side_status_editing_enabled + = render 'setting_row', var: :days_to_keep_business_registry_cache = render 'setting_row', var: :api_ip_whitelist_enabled = render 'setting_row', var: :registrar_ip_whitelist_enabled = render 'setting_row', var: :request_confrimation_on_registrant_change_enabled @@ -70,6 +72,9 @@ = render 'setting_row', var: :days_to_keep_invoices_active = render 'setting_row', var: :days_to_keep_overdue_invoices_active = render 'setting_row', var: :minimum_deposit + = render 'setting_row', var: :directo_receipt_payment_term + = render 'setting_row', var: :directo_receipt_product_name + = render 'setting_row', var: :directo_sales_agent = render 'setting_row', var: :registry_billing_email = render 'setting_row', var: :registry_invoice_contact = render 'setting_row', var: :registry_vat_no diff --git a/app/views/epp/contacts/info.xml.builder b/app/views/epp/contacts/info.xml.builder index 39aa91b39..fe851a6d9 100644 --- a/app/views/epp/contacts/info.xml.builder +++ b/app/views/epp/contacts/info.xml.builder @@ -51,7 +51,7 @@ xml.epp_head do xml.tag!('contact:crID', @contact.cr_id) xml.tag!('contact:crDate', @contact.created_at.try(:iso8601)) - if @contact.updated_at != @contact.created_at + if @contact.updated_at > @contact.created_at 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 diff --git a/app/views/epp/domains/info.xml.builder b/app/views/epp/domains/info.xml.builder index ec5947b13..ef283ab07 100644 --- a/app/views/epp/domains/info.xml.builder +++ b/app/views/epp/domains/info.xml.builder @@ -41,7 +41,7 @@ xml.epp_head do xml.tag!('domain:crID', @domain.cr_id) xml.tag!('domain:crDate', @domain.created_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 diff --git a/app/views/for_models/whois_other.erb b/app/views/for_models/whois_other.erb new file mode 100644 index 000000000..33ee735e7 --- /dev/null +++ b/app/views/for_models/whois_other.erb @@ -0,0 +1,8 @@ +Estonia .ee Top Level Domain WHOIS server + +Domain: +name: <%= @json['name'] %> +status: <%= @json['status'] %> + +Estonia .ee Top Level Domain WHOIS server +More information at http://internet.ee diff --git a/app/views/mailers/domain_mailer/expiration_reminder.html.erb b/app/views/mailers/domain_mailer/expiration_reminder.html.erb index 59f02c510..e29ca826e 100644 --- a/app/views/mailers/domain_mailer/expiration_reminder.html.erb +++ b/app/views/mailers/domain_mailer/expiration_reminder.html.erb @@ -1,7 +1,7 @@ Domeen <%= @domain.name %> on aegunud
Lugupeetud .ee domeeni kasutaja

-Domeeninimi <%= @domain.name %> on aegunud ja ei ole alates <%= l(@domain.outzone_at, format: :short) %> internetis kättesaadav. Alates <%= l(@domain.delete_at, format: :short) %> on domeen <%= @domain.name %> avatud registreerimiseks kõigile huvilistele. +Domeeninimi <%= @domain.name %> on aegunud ja ei ole alates <%= l(@domain.outzone_at, format: :date) %> internetis kättesaadav. Alates <%= l(@domain.delete_at, format: :date) %> on domeen <%= @domain.name %> avatud registreerimiseks kõigile huvilistele.

Domeeni registreeringu pikendamiseks pöörduge palun oma registripidaja <%= @domain.registrar.name %> poole. Registripidajate kontaktid leiate aadressilt www.internet.ee/registripidajad.

@@ -27,7 +27,7 @@ Tel: +372 727 1000
The <%= @domain.name %> domain has expired
Dear user of .ee domain,

-The domain name <%= @domain.name %> has expired and will not be available on the Internet from <%= l(@domain.outzone_at, format: :short) %>. From <%= l(@domain.delete_at, format: :short) %>, the <%= @domain.name %> domain will be available for registration on a first come first served basis. +The domain name <%= @domain.name %> has expired and will not be available on the Internet from <%= l(@domain.outzone_at, format: :date) %>. From <%= l(@domain.delete_at, format: :date) %>, the <%= @domain.name %> domain will be available for registration on a first come first served basis.

To renew the domain registration, please contact your registrar <%= @domain.registrar.name %>. You can find the registrar's contacts at http://www.internet.ee/en/registripidajad/.

@@ -53,7 +53,7 @@ Phone: +372 727 1000
Домен <%= @domain.name %> устарел
Уважаемый пользователь домена .ee

-Доменное имя <%= @domain.name %> устарело и с <%= l(@domain.outzone_at, format: :short) %> недоступно в Интернете. С <%= l(@domain.delete_at, format: :short) %> домен <%= @domain.name %> доступен для регистрации всем желающим по принципу "first come, first served". +Доменное имя <%= @domain.name %> устарело и с <%= l(@domain.outzone_at, format: :date) %> недоступно в Интернете. С <%= l(@domain.delete_at, format: :date) %> домен <%= @domain.name %> доступен для регистрации всем желающим по принципу "first come, first served".

Для продления регистрации домена просим обратиться к своему регистратору <%= @domain.registrar.name %>. Контактные данные регистраторов можно найти по адресу http://www.internet.ee/ru/p/.

diff --git a/app/views/mailers/domain_mailer/expiration_reminder.text.erb b/app/views/mailers/domain_mailer/expiration_reminder.text.erb index 988ae5e10..d16682ea5 100644 --- a/app/views/mailers/domain_mailer/expiration_reminder.text.erb +++ b/app/views/mailers/domain_mailer/expiration_reminder.text.erb @@ -1,7 +1,7 @@ Domeen <%= @domain.name %> on aegunud Lugupeetud .ee domeeni kasutaja -Domeeninimi <%= @domain.name %> on aegunud ja ei ole alates <%= l(@domain.outzone_at, format: :short) %> internetis kättesaadav. Alates <%= l(@domain.delete_at, format: :short) %> on domeen <%= @domain.name %> avatud registreerimiseks kõigile huvilistele. +Domeeninimi <%= @domain.name %> on aegunud ja ei ole alates <%= l(@domain.outzone_at, format: :date) %> internetis kättesaadav. Alates <%= l(@domain.delete_at, format: :date) %> on domeen <%= @domain.name %> avatud registreerimiseks kõigile huvilistele. Domeeni registreeringu pikendamiseks pöörduge palun oma registripidaja <%= @domain.registrar.name %> poole. Registripidajate kontaktid leiate aadressilt www.internet.ee/registripidajad. @@ -27,7 +27,7 @@ Tel: +372 727 1000 The <%= @domain.name %> domain has expired Dear user of .ee domain, -The domain name <%= @domain.name %> has expired and will not be available on the Internet from <%= l(@domain.outzone_at, format: :short) %>. From <%= l(@domain.delete_at, format: :short) %>, the <%= @domain.name %> domain will be available for registration on a first come first served basis. +The domain name <%= @domain.name %> has expired and will not be available on the Internet from <%= l(@domain.outzone_at, format: :date) %>. From <%= l(@domain.delete_at, format: :date) %>, the <%= @domain.name %> domain will be available for registration on a first come first served basis. To renew the domain registration, please contact your registrar <%= @domain.registrar.name %>. You can find the registrar's contacts at http://www.internet.ee/en/registripidajad/. @@ -53,7 +53,7 @@ Phone: +372 727 1000 Домен <%= @domain.name %> устарел Уважаемый пользователь домена .ee -Доменное имя <%= @domain.name %> устарело и с <%= l(@domain.outzone_at, format: :short) %> недоступно в Интернете. С <%= l(@domain.delete_at, format: :short) %> домен <%= @domain.name %> доступен для регистрации всем желающим по принципу "first come, first served". +Доменное имя <%= @domain.name %> устарело и с <%= l(@domain.outzone_at, format: :date) %> недоступно в Интернете. С <%= l(@domain.delete_at, format: :date) %> домен <%= @domain.name %> доступен для регистрации всем желающим по принципу "first come, first served". Для продления регистрации домена просим обратиться к своему регистратору <%= @domain.registrar.name %>. Контактные данные регистраторов можно найти по адресу http://www.internet.ee/ru/p/. diff --git a/app/views/mailers/domain_mailer/force_delete.html.erb b/app/views/mailers/domain_mailer/force_delete.html.erb index 82bdee156..6f4f4cb27 100644 --- a/app/views/mailers/domain_mailer/force_delete.html.erb +++ b/app/views/mailers/domain_mailer/force_delete.html.erb @@ -20,7 +20,7 @@ Registrikood: <%= @domain.registrant.try(:ident) %>

Domeenireeglite punktist 6.4 tulenevalt on domeeni suhtes õigust omaval registreerijal võimalus esitada domeeni <%= @domain.name %> registripidajale <%= @domain.registrar %> domeeni üleandmise taotlus Domeenireeglite p 5.3.6.2 kohaselt. Taotlusele tuleb lisada domeeni omandamist tõendavad dokumendid, mis asendavad Domeenireeglite punktis 5.3.6.3 sätestatud üleandva registreerija nõusolekut. Vastav dokumentatsioon tuleks esitada Registripidajale esimesel võimalusel.

-

Kui üleandmine ei ole 30 päeva jooksul toimunud, kustub domeen <%= @domain.name %> 24 tunni jooksul <%= l(@domain.force_delete_at, format: :short) %> möödumisest juhuslikult valitud ajahetkel. Soovi korral on võimalik domeen pärast selle kustumist registrist “kes ees, see mees” põhimõttel uuesti registreerida.

+

Kui üleandmine ei ole 30 päeva jooksul toimunud, kustub domeen <%= @domain.name %> 24 tunni jooksul <%= l(@domain.force_delete_at, format: :date) %> möödumisest juhuslikult valitud ajahetkel. Soovi korral on võimalik domeen pärast selle kustumist registrist “kes ees, see mees” põhimõttel uuesti registreerida.

Lisaküsimuste korral võtke palun ühendust oma registripidajaga <%= @domain.registrar %>, kelle kontaktandmed leiate lingilt http://www.internet.ee/registripidajad



@@ -39,7 +39,7 @@ Registry code: <%= @domain.registrant.try(:ident) %>

According to paragraph 6.4 of the Domain Regulation, the registrant holding a right to the domain name <%= @domain.name %> can submit a domain name transfer application to the registrar <%= @domain.registrar %> in accordance with paragraph 5.3.6.2 of the Domain Regulation. The application must be submitted together with documents certifying the acquisition of the domain that will replace the consent of the surrendering registrant as laid down in paragraph 5.3.6.3 of the Domain Regulation. The relevant documents should be submitted to the registrar as soon as possible.

-

If the transfer has not been made in 30 days, the domain <%= @domain.name %> will be deleted at a randomly chosen moment within 24 hours after <%= l(@domain.force_delete_at, format: :short) %>. After deletion it is possible to reregister the domain on a "first come, first served" basis.

+

If the transfer has not been made in 30 days, the domain <%= @domain.name %> will be deleted at a randomly chosen moment within 24 hours after <%= l(@domain.force_delete_at, format: :date) %>. After deletion it is possible to reregister the domain on a "first come, first served" basis.

Should you have additional questions, please contact your registrar <%= @domain.registrar %>, whose contact information can be found at http://www.internet.ee/registrars/



@@ -58,7 +58,7 @@ Registry code: <%= @domain.registrant.try(:ident) %>

Согласно пункту 6.4 Правил домена регистрант, имеющий право на домен, может подать регистратору <%= @domain.registrar %> домена <%= @domain.name %> ходатайство о передаче домена в соответствии с п. 5.3.6.2 Правил домена. К ходатайству следует приложить подтверждающие приобретение домена документы, заменяющие в соответствии с пунктом 5.3.6.3 Правил домена согласие передающего доменное имя регистранта. EIS предлагает представить соответствующую документацию Регистратору при первой возможности, начиная с инициирования процедуры удаления.

-

Если в течение 30 дней передача не произошла, домен <%= @domain.name %> удаляется по истечении 24 часов <%= l(@domain.force_delete_at, format: :short) %> в случайный момент времени. По желанию после удаления из регистра домен можно снова зарегистрировать по принципу "кто успел, тот и съел".

+

Если в течение 30 дней передача не произошла, домен <%= @domain.name %> удаляется по истечении 24 часов <%= l(@domain.force_delete_at, format: :date) %> в случайный момент времени. По желанию после удаления из регистра домен можно снова зарегистрировать по принципу "кто успел, тот и съел".

Просим обратиться к своему регистратору <%= @domain.registrar %>. Контактные данные регистраторов можно найти по адресу http://www.internet.ee/registratory/



diff --git a/app/views/mailers/domain_mailer/force_delete.text.erb b/app/views/mailers/domain_mailer/force_delete.text.erb index 527288686..d6369c8cb 100644 --- a/app/views/mailers/domain_mailer/force_delete.text.erb +++ b/app/views/mailers/domain_mailer/force_delete.text.erb @@ -11,7 +11,7 @@ Kuivõrd äriregistrist kustutatud juriidiline isik ei saa olla domeeni registre Domeenireeglite punktist 6.4 tulenevalt on domeeni suhtes õigust omaval registreerijal võimalus esitada domeeni <%= @domain.name %> registripidajale <%= @domain.registrar %> domeeni üleandmise taotlus Domeenireeglite p 5.3.6.2 kohaselt. Taotlusele tuleb lisada domeeni omandamist tõendavad dokumendid, mis asendavad Domeenireeglite punktis 5.3.6.3 sätestatud üleandva registreerija nõusolekut. Vastav dokumentatsioon tuleks esitada Registripidajale esimesel võimalusel. -Kui üleandmine ei ole 30 päeva jooksul toimunud, kustub domeen <%= @domain.name %> 24 tunni jooksul <%= l(@domain.force_delete_at, format: :short) %> möödumisest juhuslikult valitud ajahetkel. Soovi korral on võimalik domeen pärast selle kustumist registrist "kes ees, see mees" põhimõttel uuesti registreerida. +Kui üleandmine ei ole 30 päeva jooksul toimunud, kustub domeen <%= @domain.name %> 24 tunni jooksul <%= l(@domain.force_delete_at, format: :date) %> möödumisest juhuslikult valitud ajahetkel. Soovi korral on võimalik domeen pärast selle kustumist registrist "kes ees, see mees" põhimõttel uuesti registreerida. Lisaküsimuste korral võtke palun ühendust oma registripidajaga <%= @domain.registrar %>, kelle kontaktandmed leiate lingilt http://www.internet.ee/registripidajad/ @@ -30,7 +30,7 @@ As a terminated legal person cannot be the registrant of a domain, the EIF start According to paragraph 6.4 of the Domain Regulation, the registrant holding a right to the domain name <%= @domain.name %> can submit a domain name transfer application to the registrar <%= @domain.registrar %> in accordance with paragraph 5.3.6.2 of the Domain Regulation. The application must be submitted together with documents certifying the acquisition of the domain that will replace the consent of the surrendering registrant as laid down in paragraph 5.3.6.3 of the Domain Regulation. The relevant documents should be submitted to the registrar as soon as possible. -If the transfer has not been made in 30 days, the domain <%= @domain.name %> will be deleted at a randomly chosen moment within 24 hours after <%= l(@domain.force_delete_at, format: :short) %>. After deletion it is possible to reregister the domain on a "first come, first served" basis. +If the transfer has not been made in 30 days, the domain <%= @domain.name %> will be deleted at a randomly chosen moment within 24 hours after <%= l(@domain.force_delete_at, format: :date) %>. After deletion it is possible to reregister the domain on a "first come, first served" basis. Should you have additional questions, please contact your registrar <%= @domain.registrar %>, whose contact information can be found at http://www.internet.ee/registrars/ @@ -49,7 +49,7 @@ EIS стало известно, что юридическое лицо с ре Согласно пункту 6.4 Правил домена регистрант, имеющий право на домен, может подать регистратору <%= @domain.registrar %> домена <%= @domain.name %> ходатайство о передаче домена в соответствии с п. 5.3.6.2 Правил домена. К ходатайству следует приложить подтверждающие приобретение домена документы, заменяющие в соответствии с пунктом 5.3.6.3 Правил домена согласие передающего доменное имя регистранта. EIS предлагает представить соответствующую документацию Регистратору при первой возможности, начиная с инициирования процедуры удаления. -Если в течение 30 дней передача не произошла, домен <%= @domain.name %> удаляется по истечении 24 часов <%= l(@domain.force_delete_at, format: :short) %> в случайный момент времени. По желанию после удаления из регистра домен можно снова зарегистрировать по принципу "кто успел, тот и съел". +Если в течение 30 дней передача не произошла, домен <%= @domain.name %> удаляется по истечении 24 часов <%= l(@domain.force_delete_at, format: :date) %> в случайный момент времени. По желанию после удаления из регистра домен можно снова зарегистрировать по принципу "кто успел, тот и съел". Просим обратиться к своему регистратору <%= @domain.registrar %>. Контактные данные регистраторов можно найти по адресу http://www.internet.ee/registratory 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/registrant/contacts/partials/_address.haml b/app/views/registrant/contacts/partials/_address.haml new file mode 100644 index 000000000..9c0f548e3 --- /dev/null +++ b/app/views/registrant/contacts/partials/_address.haml @@ -0,0 +1,23 @@ +.panel.panel-default + .panel-heading + %h3.panel-title= t(:address) + .panel-body + %dl.dl-horizontal + - if @contact.org_name.present? + %dt= t(:org_name) + %dd= @contact.org_name + + %dt= t(:street) + %dd= @contact.street.to_s.gsub("\n", '
').html_safe + + %dt= t(:city) + %dd= @contact.city + + %dt= t(:zip) + %dd= @contact.zip + + %dt= t(:state) + %dd= @contact.state + + %dt= t(:country) + %dd= @contact.country diff --git a/app/views/registrant/contacts/partials/_domains.haml b/app/views/registrant/contacts/partials/_domains.haml new file mode 100644 index 000000000..d0180532d --- /dev/null +++ b/app/views/registrant/contacts/partials/_domains.haml @@ -0,0 +1,30 @@ +- domains = contact.all_domains(page: params[:domain_page], per: 20, params: params) +#contacts.panel.panel-default + .panel-heading + .pull-left + = t(:domains) + .pull-right + = form_tag request.path, method: :get do + = select_tag :domain_filter, options_for_select(%w(Registrant AdminDomainContact TechDomainContact), selected: params[:domain_filter]), + include_blank: true, class: 'form-control2 selectize2' + %button.btn.btn-primary + %span.glyphicon.glyphicon-search + .clearfix + + .table-responsive + %table.table.table-hover.table-bordered.table-condensed + %thead + %tr + %th{class: 'col-xs-3'}=custom_sort_link t(:domain_name), :name + %th{class: 'col-xs-3'}=custom_sort_link t(:registrar), :registrar_name + %th{class: 'col-xs-3'}=custom_sort_link t(:valid_to), :valid_to + %th{class: 'col-xs-3'}= t(:roles) + %tbody + - domains.each do |x| + %tr + %td= link_to(x.name, [:registrant, x]) + %td= link_to(x.registrar, [:registrant, x.registrar]) + %td= l(x.valid_to, format: :short) + %td= x.roles.join(", ") + += paginate domains, param_name: :domain_page \ No newline at end of file diff --git a/app/views/registrant/contacts/partials/_general.haml b/app/views/registrant/contacts/partials/_general.haml new file mode 100644 index 000000000..36192cb2c --- /dev/null +++ b/app/views/registrant/contacts/partials/_general.haml @@ -0,0 +1,45 @@ +.panel.panel-default + .panel-heading + %h3.panel-title= t(:general) + .panel-body + %dl.dl-horizontal + %dt= t(:id) + %dd= @contact.code + + %dt= t(:password) + %dd + = text_field_tag :auth_info, @contact.auth_info, readonly: true, class: 'partially-hidden' + + %br + + %dt= t(:ident) + %dd= ident_for(@contact) + + %dt= t(:email) + %dd= @contact.email + + %dt= t(:phone) + %dd= @contact.phone + + - if @contact.fax + %dt= t(:fax) + %dd= @contact.fax + + %br + + %dt= t(:created) + %dd + = l(@contact.created_at, format: :short) + by + = creator_link(@contact) + + %dt= t(:updated) + %dd + = l(@contact.updated_at, format: :short) + by + = updator_link(@contact) + + %dt= t(:registrar) + %dd + - if @contact.registrar.present? + = link_to(@contact.registrar, registrant_registrar_path(@contact.registrar)) diff --git a/app/views/registrant/contacts/partials/_search.haml b/app/views/registrant/contacts/partials/_search.haml new file mode 100644 index 000000000..4a723bf6b --- /dev/null +++ b/app/views/registrant/contacts/partials/_search.haml @@ -0,0 +1,6 @@ += search_form_for [:registrant, @q] do |f| + = f.search_field :name_cont + = f.submit do + %span.glyphicon.glyphicon-search + + diff --git a/app/views/registrant/contacts/partials/_statuses.haml b/app/views/registrant/contacts/partials/_statuses.haml new file mode 100644 index 000000000..c39075754 --- /dev/null +++ b/app/views/registrant/contacts/partials/_statuses.haml @@ -0,0 +1,21 @@ +- panel_class = contact.errors.messages[:statuses] ? 'panel-danger' : 'panel-default' +#contact_statuses.panel{class: panel_class} + .panel-heading.clearfix + = t(:statuses) + .table-responsive + %table.table.table-hover.table-bordered.table-condensed + %thead + %tr + %th{class: 'col-xs-6'}= t(:status) + %th{class: 'col-xs-6'}= t(:notes) + %tbody + - contact.statuses.each do |status| + %tr + %td= status + %td= contact.status_notes[status] + + - if contact.errors.messages[:statuses] + %tfoot + - @domain.errors.messages[:statuses].each do |s| + %tr + %td{colspan: 4}= s diff --git a/app/views/registrant/contacts/show.haml b/app/views/registrant/contacts/show.haml new file mode 100644 index 000000000..57915e9ff --- /dev/null +++ b/app/views/registrant/contacts/show.haml @@ -0,0 +1,12 @@ +- content_for :actions do + = render 'shared/title', name: @contact.name + +.row + .col-md-6= render 'registrant/contacts/partials/general' + .col-md-6= render 'registrant/contacts/partials/address' +.row + .col-md-12= render 'registrant/contacts/partials/statuses', contact: @contact +.row + .col-md-12= render 'registrant/contacts/partials/domains', contact: @contact + + diff --git a/app/views/registrant/domains/download_list.haml b/app/views/registrant/domains/download_list.haml new file mode 100644 index 000000000..40212812c --- /dev/null +++ b/app/views/registrant/domains/download_list.haml @@ -0,0 +1,28 @@ +!!! +%html + %head + %meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"} + %title Contacts + %body + .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(:registrant) + %th{class: 'col-xs-2'} + =t(:valid_to) + %th{class: 'col-xs-2'} + =t(:registrar) + %tbody + - @domains.result.each do |x| + %tr + %td= x.name + %td= x.registrant + %td= l(x.valid_to, format: :short) + %td= x.registrar + .row + .col-md-6 diff --git a/app/views/registrant/domains/index.haml b/app/views/registrant/domains/index.haml index 8b71cefca..776b7878d 100644 --- a/app/views/registrant/domains/index.haml +++ b/app/views/registrant/domains/index.haml @@ -1,5 +1,52 @@ = render 'shared/title', name: t(:domains) +.row + .col-md-12 + = search_form_for [:registrant, @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(:registrant_ident) + = f.search_field :registrant_ident_eq, class: 'form-control', placeholder: t(:registrant_ident) + .row + .col-md-3 + .form-group + = f.label t(:valid_to_from) + = f.search_field :valid_to_gteq, value: params[:q][:valid_to_gteq], class: 'form-control datepicker', placeholder: t(:valid_to_from) + .col-md-3 + .form-group + = f.label t(:valid_to_until) + = f.search_field :valid_to_lteq, value: params[:q][:valid_to_lteq], class: 'form-control datepicker', placeholder: t(:valid_to_until) + .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_registrant_domains_path(q: params[:q], format: "pdf") + %li= link_to 'CSV', download_list_registrant_domains_path(q: params[:q], format: "csv") + .col-md-3 + .col-md-3 + .col-md-3 + + + %hr .row .col-md-12 @@ -8,20 +55,33 @@ %thead %tr %th{class: 'col-xs-2'} - = t(:name) + = sort_link(@q, 'name') %th{class: 'col-xs-2'} - = t(:registrant) + = sort_link(@q, 'registrant_name', t(:registrant)) %th{class: 'col-xs-2'} - = t(:valid_to) + = sort_link(@q, 'valid_to', t(:valid_to)) %th{class: 'col-xs-2'} - = t(:registrar) + = sort_link(@q, 'registrar_name', t(:registrar)) %tbody - -# - @domains.each do |x| - -# %tr - -# %td= link_to(x, admin_domain_path(x)) - -# %td - -# - if x.registrant - -# = link_to(x.registrant, [:admin, x.registrant]) + - @domains.each do |x| + %tr + %td= link_to(x, registrant_domain_path(x)) + %td + - if x.registrant + = link_to(x.registrant, [:registrant, x.registrant]) if x.registrant + + %td= l(x.valid_to, format: :short) + %td= link_to(x.registrar, registrant_registrar_path(x.registrar)) if x.registrar + + .row + .col-md-6 + = paginate @domains + .col-md-6.text-right + .pagination + = t(:result_count, count: @domains.total_count) + +:coffee + $(".js-reset-form").on "click", (e) -> + e.preventDefault(); + window.location = "#{registrant_domains_path}" - -# %td= l(x.valid_to, format: :short) - -# %td= link_to(x.registrar, admin_registrar_path(x.registrar)) if x.registrar diff --git a/app/views/registrant/domains/partials/_admin_contacts.haml b/app/views/registrant/domains/partials/_admin_contacts.haml new file mode 100644 index 000000000..5e49d3fbc --- /dev/null +++ b/app/views/registrant/domains/partials/_admin_contacts.haml @@ -0,0 +1,22 @@ +- panel_class = @domain.errors.messages[:admin_contacts] ? 'panel-danger' : 'panel-default' +.panel{class: panel_class} + .panel-heading.clearfix + = t(:admin_contacts) + .table-responsive + %table.table.table-hover.table-bordered.table-condensed + %thead + %tr + %th{class: 'col-xs-4'}= t(:name) + %th{class: 'col-xs-4'}= t(:id) + %th{class: 'col-xs-4'}= t(:email) + %tbody + - @domain.admin_contacts.each do |ac| + %tr + %td= link_to(ac, registrant_contact_path(ac)) + %td= ac.code + %td= ac.email + - if @domain.errors.messages[:admin_contacts] + %tfoot + - @domain.errors.messages[:admin_contacts].each do |x| + %tr + %td{colspan: 4}= x diff --git a/app/views/registrant/domains/partials/_dnskeys.haml b/app/views/registrant/domains/partials/_dnskeys.haml new file mode 100644 index 000000000..6d5759e65 --- /dev/null +++ b/app/views/registrant/domains/partials/_dnskeys.haml @@ -0,0 +1,25 @@ +- panel_class = @domain.errors.messages[:dnskeys] ? 'panel-danger' : 'panel-default' +#dnskeys.panel{class: panel_class} + .panel-heading.clearfix + = t(:dnskeys) + .table-responsive + %table.table.table-hover.table-bordered.table-condensed + %thead + %tr + %th{class: 'col-xs-1'}= t(:flag) + %th{class: 'col-xs-1'}= t(:protocol) + %th{class: 'col-xs-1'}= t(:algorithm) + %th{class: 'col-xs-9'}= t(:public_key) + %tbody + - @domain.dnskeys.each do |x| + %tr + %td= x.flags + %td= x.protocol + %td= x.alg + %td= x.public_key + - if @domain.errors.messages[:dnskeys] + %tfoot + - @domain.errors.messages[:dnskeys].each do |x| + %tr + %td{colspan: 4}= x + diff --git a/app/views/registrant/domains/partials/_general.haml b/app/views/registrant/domains/partials/_general.haml new file mode 100644 index 000000000..d80c1ce6a --- /dev/null +++ b/app/views/registrant/domains/partials/_general.haml @@ -0,0 +1,32 @@ +.panel.panel-default + .panel-heading + %h3.panel-title= t(:general) + .panel-body + %dl.dl-horizontal + %dt= t(:name) + %dd= @domain.name + + %dt= t(:registered_at) + %dd= l(@domain.registered_at) + + %dt= t(:registrar) + %dd= link_to(@domain.registrar, registrant_registrar_path(@domain.registrar)) + + %dt= t(:authinfo_pw) + %dd + = text_field_tag :password, @domain.auth_info, readonly: true, class: 'partially-hidden' + + %dt= t(:valid_from) + %dd= l(@domain.valid_from) + + %dt= t(:valid_to) + %dd= l(@domain.valid_to) + + %dt= t(:outzone_at) + %dd= l(@domain.outzone_at) + + %dt= t(:delete_at) + %dd= l(@domain.delete_at) + + %dt= t(:force_delete_at) + %dd= l(@domain.force_delete_at) diff --git a/app/views/registrant/domains/partials/_keyrelays.haml b/app/views/registrant/domains/partials/_keyrelays.haml new file mode 100644 index 000000000..d2d39f6ba --- /dev/null +++ b/app/views/registrant/domains/partials/_keyrelays.haml @@ -0,0 +1,20 @@ +.panel{class: 'panel-default'} + .panel-heading.clearfix + = t(:keyrelays) + .table-responsive + %table.table.table-hover.table-bordered.table-condensed + %thead + %tr + %th{class: 'col-xs-4'}= t(:uploaded_at) + %th{class: 'col-xs-3'}= t(:expiry) + %th{class: 'col-xs-2'}= t(:requester) + %th{class: 'col-xs-2'}= t(:accepter) + %th{class: 'col-xs-1'}= t(:status) + %tbody + - @domain.keyrelays.includes([:requester, :accepter]).order(pa_date: :desc).each do |x| + %tr + %td= link_to(x.pa_date, [:registrar, x]) + %td= x.expiry + %td= link_to(x.requester, [:registrar, x.requester]) + %td= link_to(x.accepter, [:registrar, x.accepter]) + %td= x.status diff --git a/app/views/registrant/domains/partials/_legal_documents.haml b/app/views/registrant/domains/partials/_legal_documents.haml new file mode 100644 index 000000000..7d740977b --- /dev/null +++ b/app/views/registrant/domains/partials/_legal_documents.haml @@ -0,0 +1,14 @@ +.panel.panel-default + .panel-heading.clearfix + = t(:legal_documents) + .table-responsive + %table.table.table-hover.table-bordered.table-condensed + %thead + %tr + %th{class: 'col-xs-8'}= t(:created_at) + %th{class: 'col-xs-4'}= t(:type) + %tbody + - legal_documents.each do |x| + %tr + %td= link_to(x.created_at, [:registrar, x]) + %td= x.document_type diff --git a/app/views/registrant/domains/partials/_nameservers.haml b/app/views/registrant/domains/partials/_nameservers.haml new file mode 100644 index 000000000..db3ca759a --- /dev/null +++ b/app/views/registrant/domains/partials/_nameservers.haml @@ -0,0 +1,23 @@ +- panel_class = @domain.errors.messages[:nameservers] ? 'panel-danger' : 'panel-default' +#nameservers.panel{class: panel_class} + .panel-heading.clearfix + = t(:nameservers) + .table-responsive + %table.table.table-hover.table-bordered.table-condensed + %thead + %tr + %th{class: 'col-xs-4'}= t(:hostname) + %th{class: 'col-xs-4'}= t(:ipv4) + %th{class: 'col-xs-4'}= t(:ipv6) + %tbody + - @domain.nameservers.each do |x| + %tr + %td= x + %td= x.ipv4 + %td= x.ipv6 + - if @domain.errors.messages[:nameservers] + %tfoot + - @domain.errors.messages[:nameservers].each do |x| + %tr + %td{colspan: 3}= x + diff --git a/app/views/registrant/domains/partials/_owner.haml b/app/views/registrant/domains/partials/_owner.haml new file mode 100644 index 000000000..a7c678d56 --- /dev/null +++ b/app/views/registrant/domains/partials/_owner.haml @@ -0,0 +1,19 @@ +.panel.panel-default + .panel-heading + %h3.panel-title= t(:registrant) + .panel-body + %dl.dl-horizontal + %dt= t(:name) + %dd= link_to(@domain.registrant, [:registrar, @domain.registrant]) + + %dt= t(:id) + %dd= @domain.registrant_code + + %dt= t(:identity_code) + %dd= @domain.registrant_ident + + %dt= t(:email) + %dd= @domain.registrant_email + + %dt= t(:phone) + %dd= @domain.registrant_phone diff --git a/app/views/registrant/domains/partials/_statuses.haml b/app/views/registrant/domains/partials/_statuses.haml new file mode 100644 index 000000000..ab8e55e6c --- /dev/null +++ b/app/views/registrant/domains/partials/_statuses.haml @@ -0,0 +1,18 @@ +#domain_statuses.panel.panel-default + .panel-heading.clearfix + = t(:statuses) + .table-responsive + %table.table.table-hover.table-bordered.table-condensed + %thead + %tr + %th{class: 'col-xs-6'}= t(:status) + %th{class: 'col-xs-6'}= t(:notes) + %tbody + - @domain.statuses.each do |status| + %tr + %td + - if @domain.pending_json.present? && [DomainStatus::PENDING_UPDATE, DomainStatus::PENDING_DELETE].include?(status) + = link_to status, admin_domain_domain_versions_path(@domain.id) + - else + = status + %td= @domain.status_notes[status] diff --git a/app/views/registrant/domains/partials/_tech_contacts.haml b/app/views/registrant/domains/partials/_tech_contacts.haml new file mode 100644 index 000000000..12844a41e --- /dev/null +++ b/app/views/registrant/domains/partials/_tech_contacts.haml @@ -0,0 +1,22 @@ +- panel_class = @domain.errors.messages[:tech_contacts] ? 'panel-danger' : 'panel-default' +#tech_contacts.panel{class: panel_class} + .panel-heading.clearfix + = t(:tech_contacts) + .table-responsive + %table.table.table-hover.table-bordered.table-condensed + %thead + %tr + %th{class: 'col-xs-4'}= t(:name) + %th{class: 'col-xs-4'}= t(:id) + %th{class: 'col-xs-4'}= t(:email) + %tbody + - @domain.tech_contacts.each do |tc| + %tr + %td= link_to(tc, registrant_contact_path(tc)) + %td= tc.code + %td= tc.email + - if @domain.errors.messages[:tech_contacts] + %tfoot + - @domain.errors.messages[:tech_contacts].each do |x| + %tr + %td{colspan: 4}= x diff --git a/app/views/registrant/domains/show.haml b/app/views/registrant/domains/show.haml new file mode 100644 index 000000000..0c1ceb48e --- /dev/null +++ b/app/views/registrant/domains/show.haml @@ -0,0 +1,17 @@ +- content_for :actions do + = render 'shared/title', name: @domain.name + +.row + .col-md-6= render 'registrant/domains/partials/general' +.row + .col-md-12= render 'registrant/domains/partials/tech_contacts' +.row + .col-md-12= render 'registrant/domains/partials/admin_contacts' +.row + .col-md-12= render 'registrant/domains/partials/statuses' +.row + .col-md-12= render 'registrant/domains/partials/nameservers' +.row + .col-md-12= render 'registrant/domains/partials/dnskeys' +.row + .col-md-12= render 'registrant/domains/partials/keyrelays' diff --git a/app/views/registrant/registrants/index.haml b/app/views/registrant/registrants/index.haml new file mode 100644 index 000000000..11838d1b2 --- /dev/null +++ b/app/views/registrant/registrants/index.haml @@ -0,0 +1,112 @@ += render 'shared/title', name: t(:contacts) + +.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) +%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)) + %tbody + - @contacts.each do |contact| + %tr + %td= link_to(contact, registrar_contact_path(contact)) + %td= contact.code + %td= ident_for(contact) + %td= l(contact.created_at, format: :short) + %td + - if contact.registrar + = link_to(contact.registrar, registrar_registrar_path(contact.registrar)) + +.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/registrant/registrants/show.haml b/app/views/registrant/registrants/show.haml new file mode 100644 index 000000000..5b2a527ca --- /dev/null +++ b/app/views/registrant/registrants/show.haml @@ -0,0 +1,75 @@ += render 'shared/title', name: @contact.name + +.row + .col-md-6 + .panel.panel-default + .panel-heading + %h3.panel-title= t(:general) + .panel-body + %dl.dl-horizontal + %dt= t(:id) + %dd= @contact.code + + %dt= t(:authinfo_pw) + %dd + = text_field_tag :auth_info, @contact.auth_info, readonly: true, class: 'partially-hidden' + + %br + + %dt= t(:ident) + %dd= ident_for(@contact) + + %dt= t(:email) + %dd= @contact.email + + %dt= t(:phone) + %dd= @contact.phone + + - if @contact.fax + %dt= t(:fax) + %dd= @contact.fax + + %br + + %dt= t(:created) + %dd + = l(@contact.created_at, format: :short) + by + = creator_link(@contact) + + %dt= t(:updated) + %dd + = l(@contact.updated_at, format: :short) + by + = updator_link(@contact) + + %dt= t(:registrar) + %dd + - if @contact.registrar.present? + = link_to(@contact.registrar, registrant_registrar_path(@contact.registrar)) if @contact.registrar + + .col-md-6 + .panel.panel-default + .panel-heading + %h3.panel-title= t(:contact) + .panel-body + %dl.dl-horizontal + %dl.dl-horizontal + - if @contact.org_name.present? + %dt= t(:org_name) + %dd= @contact.org_name + + %dt= t(:street) + %dd= @contact.street.to_s.gsub("\n", '
').html_safe + + %dt= t(:city) + %dd= @contact.city + + %dt= t(:zip) + %dd= @contact.zip + + %dt= t(:state) + %dd= @contact.state + + %dt= t(:country) + %dd= @contact.country \ No newline at end of file diff --git a/app/views/registrant/registrars/index.haml b/app/views/registrant/registrars/index.haml new file mode 100644 index 000000000..0489bcf52 --- /dev/null +++ b/app/views/registrant/registrars/index.haml @@ -0,0 +1,21 @@ +- content_for :actions do + = render 'shared/title', name: t(:registrars) + +.row + .col-md-12 + .table-responsive + %table.table.table-hover.table-bordered.table-condensed + %thead + %tr + %th{class: 'col-xs-6'} + = sort_link(@q, 'name') + %th{class: 'col-xs-6'} + = sort_link(@q, 'reg_no', t(:reg_no)) + %tbody + - @registrars.each do |x| + %tr + %td= link_to(x, [:registrar, x]) + %td= x.reg_no +.row + .col-md-12 + = paginate @registrars diff --git a/app/views/registrant/registrars/show.haml b/app/views/registrant/registrars/show.haml new file mode 100644 index 000000000..ed5c72b29 --- /dev/null +++ b/app/views/registrant/registrars/show.haml @@ -0,0 +1,53 @@ += render 'shared/title', name: @registrar.name + +- if @registrar.errors.any? + - @registrar.errors.each do |attr, err| + = err + %br +- if @registrar.errors.any? + %hr +.row + .col-md-6 + .panel.panel-default + .panel-heading + %h3.panel-title= t(:general) + .panel-body + %dl.dl-horizontal + %dt= t(:name) + %dd= @registrar.name + + %dt= t(:reg_no) + %dd= @registrar.reg_no + + %dt= t(:vat_no) + %dd= @registrar.vat_no + + %dt= t(:reference_no) + %dd= @registrar.reference_no + + %dt= t(:id) + %dd= @registrar.code + + .col-md-6 + .panel.panel-default + .panel-heading + %h3.panel-title= t(:contact) + .panel-body + %dl.dl-horizontal + %dt= t(:country) + %dd= @registrar.country + + %dt= t(:address) + %dd= @registrar.address + + %dt= t(:contact_phone) + %dd= @registrar.phone + + %dt= t(:contact_email) + %dd= @registrar.email + + %dt= t(:billing_address) + %dd= @registrar.billing_address + + %dt= t(:billing_email) + %dd= @registrar.billing_email diff --git a/app/views/registrant/whois/index.haml b/app/views/registrant/whois/index.haml index 3e390eaf3..3d95af638 100644 --- a/app/views/registrant/whois/index.haml +++ b/app/views/registrant/whois/index.haml @@ -17,5 +17,5 @@ %span.glyphicon.glyphicon-search   %hr - - if @results - = @results + - if @domain + %pre= @domain.body \ No newline at end of file diff --git a/app/views/registrar/contacts/index.haml b/app/views/registrar/contacts/index.haml index ae93a82fd..2226f7c6a 100644 --- a/app/views/registrar/contacts/index.haml +++ b/app/views/registrar/contacts/index.haml @@ -31,15 +31,10 @@ .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 + .col-md-6 .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' } + = select_tag '[q][domain_contacts_type_in]', options_for_select([['admin', 'AdminDomainContact'], ['tech', 'TechDomainContact'], ['registrant', 'registrant']], params[:q][:domain_contacts_type_in]), { multiple: true, placeholder: t(:choose), class: 'form-control js-combobox' } .row .col-md-3 .form-group 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/application-example.yml b/config/application-example.yml index a1f71d78c..879b8fb30 100644 --- a/config/application-example.yml +++ b/config/application-example.yml @@ -46,6 +46,8 @@ ca_cert_path: '/home/registry/registry/shared/ca/certs/ca.crt.pem' ca_key_path: '/home/registry/registry/shared/ca/private/ca.key.pem' ca_key_password: 'your-root-key-password' +directo_invoice_url: 'https://domain/ddddd.asp' + # # EPP @@ -87,6 +89,16 @@ repp_url: 'https://repp.gitlab.eu/repp/v1/' # restful_whois_url: 'https://restful-whois.example.com' +# +# Estonian Business Registry +# +# config/secrets.yml --- arireg: {username, password} +arireg_username: 'kasutaja' +arireg_password: 'parool' +# config/environments/production.rb --- Soap::Arireg.wsdl, Soap::Arireg.host +arireg_wsdl: 'lib/schemas/testariport.wsdl' # https://demo-ariregxml.rik.ee:447/testariport/?wsdl +#arireg_wsdl: 'lib/schemas/ariport.wsdl' # https://ariregxml.rik.ee/ariport/?wsdl +arireg_host: 'https://demo-ariregxml.rik.ee:447' # https://ariregxml.rik.ee/ # # REGISTRAR AND REGISTRANT diff --git a/config/application.rb b/config/application.rb index 7734cc6e9..2121039dc 100644 --- a/config/application.rb +++ b/config/application.rb @@ -7,6 +7,8 @@ require 'action_controller/railtie' require 'action_mailer/railtie' require 'action_view/railtie' require 'sprockets/railtie' +require 'csv' +require 'rails/all' # require "rails/test_unit/railtie" # Require the gems listed in Gemfile, including any gems diff --git a/config/environments/production.rb b/config/environments/production.rb index 58258e710..e47420a27 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -70,7 +70,7 @@ Rails.application.configure do config.i18n.fallbacks = true # Send deprecation notices to registered listeners. - config.active_support.deprecation = :notify + config.active_support.deprecation = :log # Disable automatic flushing of the log to improve performance. # config.autoflush_log = false diff --git a/config/environments/staging.rb b/config/environments/staging.rb index 0a5e3ecae..7ffc82641 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -70,7 +70,7 @@ Rails.application.configure do config.i18n.fallbacks = true # Send deprecation notices to registered listeners. - config.active_support.deprecation = :notify + config.active_support.deprecation = :log # Disable automatic flushing of the log to improve performance. # config.autoflush_log = false diff --git a/config/initializers/eis_ransack.rb b/config/initializers/eis_ransack.rb new file mode 100644 index 000000000..c23791ef7 --- /dev/null +++ b/config/initializers/eis_ransack.rb @@ -0,0 +1,40 @@ +# A custom initializer that enables sorting via custom scopes in Ransack (like the same feature in MetaSearch) + +module Ransack + module Adapters + module ActiveRecord + class Context < ::Ransack::Context + + # Allows for sorting by custom scopes + # + # + # Define your custom scopes in your model, e. g. sort_by_title_asc and sort_by_title_desc + # (The scopes would sort by some calculated column or a column added via some crazy join, etc.) + # + # In your sort links refer to the scopes like to standard fields, e. g. + # <%= sort_link(@q, :title, 'Crazy calculated title') %> + def evaluate(search, opts = {}) + viz = Visitor.new + relation = @object.where(viz.accept(search.base)) + if search.sorts.any? + custom_scopes = search.sorts.select do |s| + custom_scope_name = :"sort_by_#{s.name}_#{s.dir}" + relation.respond_to?(custom_scope_name) + end + attribute_scopes = search.sorts - custom_scopes + + relation = relation.except(:order) + + custom_scopes.each do |s| + custom_scope_name = :"sort_by_#{s.name}_#{s.dir}" + relation = relation.public_send(custom_scope_name) + end + + relation = relation.reorder(viz.accept(attribute_scopes)) if attribute_scopes.any? + end + opts[:distinct] ? relation.distinct : relation + end + end + end + end +end \ No newline at end of file diff --git a/config/initializers/initial_settings.rb b/config/initializers/initial_settings.rb index 812641a09..eb333943f 100644 --- a/config/initializers/initial_settings.rb +++ b/config/initializers/initial_settings.rb @@ -28,15 +28,21 @@ if con.present? && con.table_exists?('settings') Setting.save_default(:client_side_status_editing_enabled, false) + Setting.save_default(:days_to_keep_business_registry_cache, 2) + Setting.save_default(:invoice_number_min, 131050) Setting.save_default(:invoice_number_max, 149999) Setting.save_default(:days_to_keep_invoices_active, 30) Setting.save_default(:days_to_keep_overdue_invoices_active, 30) Setting.save_default(:minimum_deposit, 0.0) + Setting.save_default(:directo_receipt_payment_term, "R") + Setting.save_default(:directo_receipt_product_name, "ETTEM06") + Setting.save_default(:directo_sales_agent, "JAANA") Setting.save_default(:days_to_renew_domain_before_expire, 90) Setting.save_default(:expire_warning_period, 15) Setting.save_default(:redemption_grace_period, 30) + Setting.save_default(:expiration_reminder_mail, 2) Setting.save_default(:registrar_ip_whitelist_enabled, true) Setting.save_default(:api_ip_whitelist_enabled, true) diff --git a/config/locales/en.yml b/config/locales/en.yml index 16e643b16..27495c382 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -49,6 +49,7 @@ en: ident: blank: "Required parameter missing - ident" invalid_EE_identity_format: "Ident not in valid Estonian identity format." + invalid_EE_identity_format_update: "Ident not in valid Estonian identity format. Please create new contact" invalid_birthday_format: "Ident not in valid birthady format, should be YYYY-MM-DD" invalid_country_code: "Ident country code is not valid, should be in ISO_3166-1 alpha 2 format" domains: @@ -280,6 +281,7 @@ en: domain_details: 'Domain details' registered_at: 'Registered at' password: 'Password' + authinfo_pw: 'AuthInfo pw' valid_from: 'Valid from' general: 'General' contacts: 'Contacts' @@ -351,6 +353,8 @@ en: status: 'Status' eedirekt: 'EEDirekt' contact: 'Contact' + credit_balance: 'Credit balance' + starting_balance: 'Starting balance' domain_transfer_requested: 'Domain transfer requested!' domain_transfer_approved: 'Domain transfer approved!' @@ -533,6 +537,7 @@ en: switch_to: Switch to admin_menu: Admin domain_transfer_was_approved: 'Domain transfer was approved, associated contacts were: %{contacts} and registrant was %{registrant}' + business_registry_service_not_available: "Business Registry service Ärireg is not available" # DEPP activemodel: @@ -554,6 +559,7 @@ en: username: 'Username' password: 'Password' + authinfo_pw: 'AuthInfo pw' log_in: 'Log in' domains: 'Domains' register: 'Register' @@ -904,7 +910,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 @@ -926,3 +932,8 @@ en: if_auth_info_is_left_empty_it_will_be_auto_generated: 'If auth info is left empty, it will be auto generated.' each_domain_name_must_end_with_colon_sign: 'Each domain name must end with colon (:) sign.' expiration_remind_subject: 'The %{name} domain has expired' + contact_already_associated_with_the_domain: 'Object association prohibits operation, contact already associated with the domain' + add_reserved_domain: 'Add domain to reserved list' + add_blocked_domain: 'Add domain to blocked list' + edit_pw: 'Edit Pw' + optional: 'Optional' diff --git a/config/routes.rb b/config/routes.rb index 9dd7faf7d..e0a331256 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -103,6 +103,12 @@ Rails.application.routes.draw do namespace :registrant do root 'domains#index' + resources :domains do + collection do + get :download_list + end + end + # resources :invoices do # member do # get 'download_pdf' @@ -141,6 +147,17 @@ Rails.application.routes.draw do end end + resources :registrars do + resources :api_users + resources :white_ips + collection do + get :search + end + end + + resources :registrants + resources :contacts + resources :whois # resources :contacts do # member do @@ -204,8 +221,16 @@ Rails.application.routes.draw do resources :settings - resources :blocked_domains - resources :reserved_domains + resources :blocked_domains do + member do + get 'delete' + end + end + resources :reserved_domains do + member do + get 'delete' + end + end resources :registrars do resources :api_users diff --git a/config/schedule.rb b/config/schedule.rb index 5524f10ab..b364f59e0 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -31,7 +31,7 @@ if @cron_group == 'registry' # end every :day, at: '12:20am' do - runner 'Domain.clean_expired_pendings' + runner 'DomainCron.clean_expired_pendings' end every 3.hours do @@ -39,20 +39,24 @@ if @cron_group == 'registry' end every 42.minutes do - runner 'Domain.destroy_delete_candidates' + runner 'DomainCron.destroy_delete_candidates' end every 45.minutes do - runner 'Domain.start_expire_period' + runner 'DomainCron.start_expire_period' end every 50.minutes do - runner 'Domain.start_delete_period' + runner 'DomainCron.start_delete_period' end every 52.minutes do - runner 'Domain.start_redemption_grace_period' + runner 'DomainCron.start_redemption_grace_period' end + + every :day, at: '19:00pm' do + runner 'Directo.send_receipts' + end if @environment == 'production' end every 10.minutes do diff --git a/db/migrate/20151202123506_name_and_password_for_reserved_domain.rb b/db/migrate/20151202123506_name_and_password_for_reserved_domain.rb new file mode 100644 index 000000000..3e4f16500 --- /dev/null +++ b/db/migrate/20151202123506_name_and_password_for_reserved_domain.rb @@ -0,0 +1,18 @@ +class NameAndPasswordForReservedDomain < ActiveRecord::Migration + def up + add_column :reserved_domains, :name, :string + add_column :reserved_domains, :password, :string + add_index :reserved_domains, :name + + ReservedDomain.find_each do |domain| + names = domain.names + domain.update_columns(name: names.keys.first, password: names.values.first) + end + + remove_column :reserved_domains, :names + end + + def down + + end +end diff --git a/db/migrate/20151209122816_create_business_registry_caches.rb b/db/migrate/20151209122816_create_business_registry_caches.rb new file mode 100644 index 000000000..3d7766a60 --- /dev/null +++ b/db/migrate/20151209122816_create_business_registry_caches.rb @@ -0,0 +1,13 @@ +class CreateBusinessRegistryCaches < ActiveRecord::Migration + def change + create_table :business_registry_caches do |t| + t.string :ident + t.string :ident_country_code + t.datetime :retrieved_on + t.string :associated_businesses, array: true + t.timestamps null: false + end + + add_index :business_registry_caches, :ident + end +end diff --git a/db/migrate/20160108135436_name_and_password_for_blocked_domain.rb b/db/migrate/20160108135436_name_and_password_for_blocked_domain.rb new file mode 100644 index 000000000..efd46ac88 --- /dev/null +++ b/db/migrate/20160108135436_name_and_password_for_blocked_domain.rb @@ -0,0 +1,11 @@ +class NameAndPasswordForBlockedDomain < ActiveRecord::Migration + def up + add_column :blocked_domains, :name, :string + add_index :blocked_domains, :name + remove_column :blocked_domains, :names + end + + def down + + end +end diff --git a/db/migrate/20160113143447_create_directos.rb b/db/migrate/20160113143447_create_directos.rb new file mode 100644 index 000000000..2fb6f85f8 --- /dev/null +++ b/db/migrate/20160113143447_create_directos.rb @@ -0,0 +1,10 @@ +class CreateDirectos < ActiveRecord::Migration + def change + create_table :directos do |t| + t.belongs_to :item, index: true, polymorphic: true + t.json :response + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20160118092454_add_in_directo_to_invoice.rb b/db/migrate/20160118092454_add_in_directo_to_invoice.rb new file mode 100644 index 000000000..0e93c3835 --- /dev/null +++ b/db/migrate/20160118092454_add_in_directo_to_invoice.rb @@ -0,0 +1,5 @@ +class AddInDirectoToInvoice < ActiveRecord::Migration + def change + add_column :invoices, :in_directo, :boolean, default: false + end +end diff --git a/db/migrate/20160218102355_index_domain_statuses.rb b/db/migrate/20160218102355_index_domain_statuses.rb new file mode 100644 index 000000000..d7bb787cb --- /dev/null +++ b/db/migrate/20160218102355_index_domain_statuses.rb @@ -0,0 +1,5 @@ +class IndexDomainStatuses < ActiveRecord::Migration + def change + add_index :domains, :statuses, using: :gin + end +end diff --git a/db/schema-read-only.rb b/db/schema-read-only.rb index b362619b0..78722223a 100644 --- a/db/schema-read-only.rb +++ b/db/schema-read-only.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20151029152638) do +ActiveRecord::Schema.define(version: 20160108135436) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -135,13 +135,15 @@ ActiveRecord::Schema.define(version: 20151029152638) do end create_table "blocked_domains", force: :cascade do |t| - t.string "names", array: true t.datetime "created_at" t.datetime "updated_at" t.string "creator_str" t.string "updator_str" + t.string "name" end + add_index "blocked_domains", ["name"], name: "index_blocked_domains_on_name", using: :btree + create_table "cached_nameservers", id: false, force: :cascade do |t| t.string "hostname", limit: 255 t.string "ipv4", limit: 255 @@ -240,19 +242,20 @@ ActiveRecord::Schema.define(version: 20151029152638) do end create_table "dnskeys", force: :cascade do |t| - t.integer "domain_id" - t.integer "flags" - t.integer "protocol" - t.integer "alg" - t.text "public_key" - t.integer "delegation_signer_id" - t.string "ds_key_tag" - t.integer "ds_alg" - t.integer "ds_digest_type" - t.string "ds_digest" - t.string "creator_str" - t.string "updator_str" - t.integer "legacy_domain_id" + t.integer "domain_id" + t.integer "flags" + t.integer "protocol" + t.integer "alg" + t.text "public_key" + t.integer "delegation_signer_id" + t.string "ds_key_tag" + t.integer "ds_alg" + t.integer "ds_digest_type" + t.string "ds_digest" + t.string "creator_str" + t.string "updator_str" + t.integer "legacy_domain_id" + t.datetime "updated_at" end add_index "dnskeys", ["delegation_signer_id"], name: "index_dnskeys_on_delegation_signer_id", using: :btree @@ -336,6 +339,7 @@ ActiveRecord::Schema.define(version: 20151029152638) do end add_index "domains", ["delete_at"], name: "index_domains_on_delete_at", using: :btree + add_index "domains", ["name"], name: "index_domains_on_name", unique: true, using: :btree add_index "domains", ["outzone_at"], name: "index_domains_on_outzone_at", using: :btree add_index "domains", ["registrant_id"], name: "index_domains_on_registrant_id", using: :btree add_index "domains", ["registrant_verification_asked_at"], name: "index_domains_on_registrant_verification_asked_at", using: :btree @@ -442,9 +446,7 @@ ActiveRecord::Schema.define(version: 20151029152638) do t.integer "documentable_id" t.string "documentable_type" t.datetime "created_at" - t.datetime "updated_at" t.string "creator_str" - t.string "updator_str" t.string "path" end @@ -739,21 +741,6 @@ ActiveRecord::Schema.define(version: 20151029152638) do add_index "log_keyrelays", ["item_type", "item_id"], name: "index_log_keyrelays_on_item_type_and_item_id", using: :btree add_index "log_keyrelays", ["whodunnit"], name: "index_log_keyrelays_on_whodunnit", using: :btree - create_table "log_legal_documents", force: :cascade do |t| - t.string "item_type", null: false - t.integer "item_id", null: false - t.string "event", null: false - t.string "whodunnit" - t.json "object" - t.json "object_changes" - t.datetime "created_at" - t.string "session" - t.json "children" - end - - add_index "log_legal_documents", ["item_type", "item_id"], name: "index_log_legal_documents_on_item_type_and_item_id", using: :btree - add_index "log_legal_documents", ["whodunnit"], name: "index_log_legal_documents_on_whodunnit", using: :btree - create_table "log_messages", force: :cascade do |t| t.string "item_type", null: false t.integer "item_id", null: false @@ -910,10 +897,10 @@ ActiveRecord::Schema.define(version: 20151029152638) do create_table "nameservers", force: :cascade do |t| t.string "hostname" - t.string "ipv4" + t.string "ipv4", default: [], array: true t.datetime "created_at" t.datetime "updated_at" - t.string "ipv6" + t.string "ipv6", default: [], array: true t.integer "domain_id" t.string "creator_str" t.string "updator_str" @@ -1011,9 +998,13 @@ ActiveRecord::Schema.define(version: 20151029152638) do t.datetime "updated_at" t.string "creator_str" t.string "updator_str" - t.hstore "names" + t.integer "legacy_id" + t.string "name" + t.string "password" end + add_index "reserved_domains", ["name"], name: "index_reserved_domains_on_name", using: :btree + create_table "settings", force: :cascade do |t| t.string "var", null: false t.text "value" diff --git a/db/seeds.rb b/db/seeds.rb index 636ff4361..ac6da0598 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -73,7 +73,7 @@ admin3 = { [admin1, admin2, admin3].each do |at| admin = AdminUser.where(at) next if admin.present? - admin = AdminUser.new(at.merge({ password_confirmation: 'testtest' })) + admin = AdminUser.new(at.merge({ password_confirmation: 'testtest', password: 'testtest' })) admin.roles = ['admin'] admin.save end diff --git a/db/structure.sql b/db/structure.sql index b2480a04e..cf413eff1 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -39,6 +39,242 @@ COMMENT ON EXTENSION hstore IS 'data type for storing sets of (key, value) pairs SET search_path = public, pg_catalog; +-- +-- Name: change_ident_country(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION change_ident_country() RETURNS boolean + LANGUAGE plpgsql + AS $_$ +DECLARE + changed BOOLEAN; + multiplier INT []; + multiplier2 INT []; + multiplier3 INT []; + multiplier4 INT []; + r RECORD; + control TEXT; + total INT; + i INT; + mod INT; + counter INT; +BEGIN + + multiplier := ARRAY [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]; + + multiplier2 := ARRAY [3, 4, 5, 6, 7, 8, 9, 1, 2, 3]; + + multiplier3 := ARRAY [1, 2, 3, 4, 5, 6, 7]; + + multiplier4 := ARRAY [3, 4, 5, 6, 7, 8, 9]; + + FOR r IN SELECT id, ident FROM contacts WHERE ident_type = 'priv' /*AND ident_country_code IS NULL*/ + LOOP + IF (length(r.ident) = 11 AND (r.ident ~ '^[0-9]+$') AND (substring(r.ident, 1, 1) = '3' OR substring(r.ident, 1, 1) = '4' OR substring(r.ident, 1, 1) = '5' OR substring(r.ident, 1, 1) = '6')) + THEN + total := 0; + counter := 1; + FOREACH i IN ARRAY multiplier + LOOP + total := (total + (i * to_number(substring(r.ident, counter, 1), '9'))); + counter := (counter + 1); + END LOOP; + mod := (total % 11); + counter := 1; + + IF (mod >= 10) + THEN + total = 0; + FOREACH i IN ARRAY multiplier2 + LOOP + total := (total + (i * to_number(substring(r.ident, counter, 1), '9'))); + counter := (counter + 1); + END LOOP; + mod := (total % 11); + END IF; + + IF (mod < 10 AND substring(r.ident, 11, 1) = to_char(mod, 'FM999MI')) + THEN + UPDATE contacts SET ident_country_code = 'EE' WHERE id = r.id; + END IF; + total = 0; + END IF; + END LOOP; + + FOR r IN SELECT id, ident FROM contacts WHERE ident_type = 'org' + LOOP + IF (length(r.ident) = 8 AND (r.ident ~ '^[0-9]+$') AND (substring(r.ident, 1, 1) = '1' OR substring(r.ident, 1, 1) = '8' OR substring(r.ident, 1, 1) = '9')) + THEN + total := 0; + counter := 1; + FOREACH i IN ARRAY multiplier3 + LOOP + total := (total + (i * to_number(substring(r.ident, counter, 1), '9'))); + counter := (counter + 1); + END LOOP; + mod := total % 11; + total = 0; + counter := 1; + + IF (mod >= 10) + THEN + total = 0; + FOREACH i IN ARRAY multiplier4 + LOOP + total := (total + (i * to_number(substring(r.ident, counter, 1), '9'))); + counter := (counter + 1); + END LOOP; + mod := (total % 11); + END IF; + + IF (mod < 10 AND (substring(r.ident, 8, 1) = to_char(mod, 'FM999MI'))) + THEN + UPDATE contacts SET ident_country_code = 'EE' WHERE id = r.id; + END IF; + END IF; + END LOOP; + + + + RETURN changed; +END; +$_$; + + +-- +-- Name: change_ident_country(integer, text); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION change_ident_country(id integer, type text) RETURNS boolean + LANGUAGE plpgsql + AS $_$ +DECLARE + changed BOOLEAN; + multiplier int[]; + multiplier2 int[]; + code int; +BEGIN + + multiplier := ARRAY[1, 2, 3, 4, 5, 6, 7, 8, 9, 1]; + + multiplier2 := ARRAY[3, 4, 5, 6, 7, 8, 9, 1, 2, 3]; + + code := (SELECT code FROM contacts WHERE id = 208 AND ident_country_code = 'EE'); + + + + UPDATE contacts + SET ident = '' + WHERE id = $1 and ident_type = $2 AND ident_country_code = 'EE' + AND ident = ''; + + RETURN changed; +END; +$_$; + + +-- +-- Name: fill_ident_country(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION fill_ident_country() RETURNS boolean + LANGUAGE plpgsql + AS $_$ + DECLARE + changed BOOLEAN; + multiplier INT []; + multiplier2 INT []; + multiplier3 INT []; + multiplier4 INT []; + r RECORD; + control TEXT; + total INT; + i INT; + mod INT; + counter INT; + BEGIN + + multiplier := ARRAY [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]; + multiplier2 := ARRAY [3, 4, 5, 6, 7, 8, 9, 1, 2, 3]; + multiplier3 := ARRAY [1, 2, 3, 4, 5, 6, 7]; + multiplier4 := ARRAY [3, 4, 5, 6, 7, 8, 9]; + + FOR r IN SELECT id, ident FROM contacts WHERE ident_type = 'priv' AND ident_country_code IS NULL + LOOP + IF (length(r.ident) = 11 AND (r.ident ~ '^[0-9]+$') AND (substring(r.ident, 1, 1) = '3' OR substring(r.ident, 1, 1) = '4' OR substring(r.ident, 1, 1) = '5' OR substring(r.ident, 1, 1) = '6')) + THEN + total := 0; + counter := 1; + FOREACH i IN ARRAY multiplier + LOOP + total := (total + (i * to_number(substring(r.ident, counter, 1), '9'))); + counter := (counter + 1); + END LOOP; + mod := (total % 11); + counter := 1; + IF (mod >= 10) + THEN + total = 0; + FOREACH i IN ARRAY multiplier2 + LOOP + total := (total + (i * to_number(substring(r.ident, counter, 1), '9'))); + counter := (counter + 1); + END LOOP; + mod := (total % 11); + END IF; + + IF (mod = 10) + THEN + mod := 0; + END IF; + + IF (substring(r.ident, 11, 1) = to_char(mod, 'FM999MI')) + THEN + UPDATE contacts SET ident_country_code = 'EE' WHERE id = r.id; + END IF; + total := 0; + END IF; + END LOOP; + + FOR r IN SELECT id, ident FROM contacts WHERE ident_type = 'org' AND ident_country_code IS NULL + LOOP + IF (length(r.ident) = 8 AND (r.ident ~ '^[0-9]+$') AND (substring(r.ident, 1, 1) = '1' OR substring(r.ident, 1, 1) = '8' OR substring(r.ident, 1, 1) = '9')) + THEN + total := 0; + counter := 1; + FOREACH i IN ARRAY multiplier3 + LOOP + total := (total + (i * to_number(substring(r.ident, counter, 1), '9'))); + counter := (counter + 1); + END LOOP; + mod := total % 11; + total := 0; + counter := 1; + IF (mod >= 10) + THEN + total = 0; + FOREACH i IN ARRAY multiplier4 + LOOP + total := (total + (i * to_number(substring(r.ident, counter, 1), '9'))); + counter := (counter + 1); + END LOOP; + mod := (total % 11); + END IF; + IF (mod = 10) + THEN + mod := 0; + END IF; + IF (substring(r.ident, 8, 1) = to_char(mod, 'FM999MI')) + THEN + UPDATE contacts SET ident_country_code = 'EE' WHERE id = r.id; + END IF; + END IF; + END LOOP; + RETURN changed; + END; + $_$; + + -- -- Name: generate_zonefile(character varying); Type: FUNCTION; Schema: public; Owner: - -- @@ -55,7 +291,7 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text ret text; BEGIN -- define filters - include_filter = '%.' || i_origin; + include_filter = '%' || i_origin; -- for %.%.% IF i_origin ~ '\.' THEN @@ -82,10 +318,6 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text ret = concat(tmp_var, chr(10), chr(10)); - -- origin ns records - SELECT ns_records FROM zonefile_settings zf WHERE i_origin = zf.origin INTO tmp_var; - ret := concat(ret, '; Zone NS Records', chr(10), tmp_var, chr(10)); - -- ns records SELECT array_to_string( array( @@ -93,17 +325,26 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text FROM domains d JOIN nameservers ns ON ns.domain_id = d.id WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter - AND NOT ('{serverHold,clientHold}' && d.statuses) ORDER BY d.name ), chr(10) ) INTO tmp_var; - ret := concat(ret, tmp_var, chr(10), chr(10)); + ret := concat(ret, '; Zone NS Records', chr(10), tmp_var, chr(10), chr(10)); - -- origin a glue records - SELECT a_records FROM zonefile_settings zf WHERE i_origin = zf.origin INTO tmp_var; - ret := concat(ret, '; Zone A Records', chr(10), tmp_var, chr(10)); + -- a glue records for origin nameservers + SELECT array_to_string( + array( + SELECT concat(ns.hostname, '. IN A ', ns.ipv4) + FROM nameservers ns + JOIN domains d ON d.id = ns.domain_id + WHERE d.name = i_origin + AND ns.hostname LIKE '%.' || d.name + AND ns.ipv4 IS NOT NULL AND ns.ipv4 <> '' + ), chr(10) + ) INTO tmp_var; + + ret := concat(ret, '; Zone A Records', chr(10), tmp_var); -- a glue records for other nameservers SELECT array_to_string( @@ -115,15 +356,43 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text AND ns.hostname LIKE '%.' || d.name AND d.name <> i_origin AND ns.ipv4 IS NOT NULL AND ns.ipv4 <> '' - AND NOT ('{serverHold,clientHold}' && d.statuses) + AND NOT EXISTS ( -- filter out glue records that already appeared in origin glue recrods + SELECT 1 FROM nameservers nsi + JOIN domains di ON nsi.domain_id = di.id + WHERE di.name = i_origin + AND nsi.hostname = ns.hostname + ) ), chr(10) ) INTO tmp_var; - ret := concat(ret, tmp_var, chr(10), chr(10)); + -- TODO This is a possible subtitition to the previous query, stress testing is needed to see which is faster - -- origin aaaa glue records - SELECT a4_records FROM zonefile_settings zf WHERE i_origin = zf.origin INTO tmp_var; - ret := concat(ret, '; Zone AAAA Records', chr(10), tmp_var, chr(10)); + -- SELECT ns.* + -- FROM nameservers ns + -- JOIN domains d ON d.id = ns.domain_id + -- WHERE d.name LIKE '%ee' AND d.name NOT LIKE '%pri.ee' + -- AND ns.hostname LIKE '%.' || d.name + -- AND d.name <> 'ee' + -- AND ns.ipv4 IS NOT NULL AND ns.ipv4 <> '' + -- AND ns.hostname NOT IN ( + -- SELECT ns.hostname FROM domains d JOIN nameservers ns ON d.id = ns.domain_id WHERE d.name = 'ee' + -- ) + + ret := concat(ret, chr(10), tmp_var, chr(10), chr(10)); + + -- aaaa glue records for origin nameservers + SELECT array_to_string( + array( + SELECT concat(ns.hostname, '. IN AAAA ', ns.ipv6) + FROM nameservers ns + JOIN domains d ON d.id = ns.domain_id + WHERE d.name = i_origin + AND ns.hostname LIKE '%.' || d.name + AND ns.ipv6 IS NOT NULL AND ns.ipv6 <> '' + ), chr(10) + ) INTO tmp_var; + + ret := concat(ret, '; Zone AAAA Records', chr(10), tmp_var); -- aaaa glue records for other nameservers SELECT array_to_string( @@ -135,23 +404,27 @@ CREATE FUNCTION generate_zonefile(i_origin character varying) RETURNS text AND ns.hostname LIKE '%.' || d.name AND d.name <> i_origin AND ns.ipv6 IS NOT NULL AND ns.ipv6 <> '' - AND NOT ('{serverHold,clientHold}' && d.statuses) + AND NOT EXISTS ( -- filter out glue records that already appeared in origin glue recrods + SELECT 1 FROM nameservers nsi + JOIN domains di ON nsi.domain_id = di.id + WHERE di.name = i_origin + AND nsi.hostname = ns.hostname + ) ), chr(10) ) INTO tmp_var; - ret := concat(ret, tmp_var, chr(10), chr(10)); + ret := concat(ret, chr(10), tmp_var, chr(10), chr(10)); -- ds records SELECT array_to_string( array( SELECT concat( - d.name_puny, '. IN DS ', dk.ds_key_tag, ' ', - dk.ds_alg, ' ', dk.ds_digest_type, ' ( ', dk.ds_digest, ' )' + d.name_puny, '. 3600 IN DS ', dk.ds_key_tag, ' ', + dk.ds_alg, ' ', dk.ds_digest_type, ' ', dk.ds_digest ) FROM domains d JOIN dnskeys dk ON dk.domain_id = d.id - WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter AND dk.flags = 257 - AND NOT ('{serverHold,clientHold}' && d.statuses) + WHERE d.name LIKE include_filter AND d.name NOT LIKE exclude_filter ), chr(10) ) INTO tmp_var; @@ -457,11 +730,11 @@ ALTER SEQUENCE banklink_transactions_id_seq OWNED BY banklink_transactions.id; CREATE TABLE blocked_domains ( id integer NOT NULL, - names character varying[], created_at timestamp without time zone, updated_at timestamp without time zone, creator_str character varying, - updator_str character varying + updator_str character varying, + name character varying ); @@ -745,7 +1018,8 @@ CREATE TABLE dnskeys ( ds_digest character varying, creator_str character varying, updator_str character varying, - legacy_domain_id integer + legacy_domain_id integer, + updated_at timestamp without time zone ); @@ -1130,9 +1404,7 @@ CREATE TABLE legal_documents ( documentable_id integer, documentable_type character varying, created_at timestamp without time zone, - updated_at timestamp without time zone, creator_str character varying, - updator_str character varying, path character varying ); @@ -1863,43 +2135,6 @@ CREATE SEQUENCE log_keyrelays_id_seq ALTER SEQUENCE log_keyrelays_id_seq OWNED BY log_keyrelays.id; --- --- Name: log_legal_documents; Type: TABLE; Schema: public; Owner: -; Tablespace: --- - -CREATE TABLE log_legal_documents ( - id integer NOT NULL, - item_type character varying NOT NULL, - item_id integer NOT NULL, - event character varying NOT NULL, - whodunnit character varying, - object json, - object_changes json, - created_at timestamp without time zone, - session character varying, - children json -); - - --- --- Name: log_legal_documents_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE log_legal_documents_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: log_legal_documents_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE log_legal_documents_id_seq OWNED BY log_legal_documents.id; - - -- -- Name: log_messages; Type: TABLE; Schema: public; Owner: -; Tablespace: -- @@ -2313,10 +2548,10 @@ ALTER SEQUENCE messages_id_seq OWNED BY messages.id; CREATE TABLE nameservers ( id integer NOT NULL, hostname character varying, - ipv4 character varying, + ipv4 character varying[] DEFAULT '{}'::character varying[], created_at timestamp without time zone, updated_at timestamp without time zone, - ipv6 character varying, + ipv6 character varying[] DEFAULT '{}'::character varying[], domain_id integer, creator_str character varying, updator_str character varying, @@ -2560,7 +2795,9 @@ CREATE TABLE reserved_domains ( updated_at timestamp without time zone, creator_str character varying, updator_str character varying, - names hstore + legacy_id integer, + name character varying, + password character varying ); @@ -3126,13 +3363,6 @@ ALTER TABLE ONLY log_invoices ALTER COLUMN id SET DEFAULT nextval('log_invoices_ ALTER TABLE ONLY log_keyrelays ALTER COLUMN id SET DEFAULT nextval('log_keyrelays_id_seq'::regclass); --- --- Name: id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY log_legal_documents ALTER COLUMN id SET DEFAULT nextval('log_legal_documents_id_seq'::regclass); - - -- -- Name: id; Type: DEFAULT; Schema: public; Owner: - -- @@ -3645,14 +3875,6 @@ ALTER TABLE ONLY log_keyrelays ADD CONSTRAINT log_keyrelays_pkey PRIMARY KEY (id); --- --- Name: log_legal_documents_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: --- - -ALTER TABLE ONLY log_legal_documents - ADD CONSTRAINT log_legal_documents_pkey PRIMARY KEY (id); - - -- -- Name: log_messages_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: -- @@ -3880,6 +4102,13 @@ CREATE INDEX index_accounts_on_registrar_id ON accounts USING btree (registrar_i CREATE INDEX index_api_users_on_registrar_id ON api_users USING btree (registrar_id); +-- +-- Name: index_blocked_domains_on_name; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- + +CREATE INDEX index_blocked_domains_on_name ON blocked_domains USING btree (name); + + -- -- Name: index_cached_nameservers_on_hostname_and_ipv4_and_ipv6; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -3985,6 +4214,13 @@ CREATE INDEX index_domain_transfers_on_domain_id ON domain_transfers USING btree CREATE INDEX index_domains_on_delete_at ON domains USING btree (delete_at); +-- +-- Name: index_domains_on_name; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- + +CREATE UNIQUE INDEX index_domains_on_name ON domains USING btree (name); + + -- -- Name: index_domains_on_outzone_at; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -4349,20 +4585,6 @@ CREATE INDEX index_log_keyrelays_on_item_type_and_item_id ON log_keyrelays USING CREATE INDEX index_log_keyrelays_on_whodunnit ON log_keyrelays USING btree (whodunnit); --- --- Name: index_log_legal_documents_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: --- - -CREATE INDEX index_log_legal_documents_on_item_type_and_item_id ON log_legal_documents USING btree (item_type, item_id); - - --- --- Name: index_log_legal_documents_on_whodunnit; Type: INDEX; Schema: public; Owner: -; Tablespace: --- - -CREATE INDEX index_log_legal_documents_on_whodunnit ON log_legal_documents USING btree (whodunnit); - - -- -- Name: index_log_messages_on_item_type_and_item_id; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -4510,6 +4732,13 @@ CREATE INDEX index_registrant_verifications_on_domain_id ON registrant_verificat CREATE INDEX index_registrars_on_code ON registrars USING btree (code); +-- +-- Name: index_reserved_domains_on_name; Type: INDEX; Schema: public; Owner: -; Tablespace: +-- + +CREATE INDEX index_reserved_domains_on_name ON reserved_domains USING btree (name); + + -- -- Name: index_settings_on_thing_type_and_thing_id_and_var; Type: INDEX; Schema: public; Owner: -; Tablespace: -- @@ -4947,5 +5176,27 @@ INSERT INTO schema_migrations (version) VALUES ('20150921110152'); INSERT INTO schema_migrations (version) VALUES ('20150921111842'); +INSERT INTO schema_migrations (version) VALUES ('20151028183132'); + INSERT INTO schema_migrations (version) VALUES ('20151029152638'); +INSERT INTO schema_migrations (version) VALUES ('20151112160452'); + +INSERT INTO schema_migrations (version) VALUES ('20151117081204'); + +INSERT INTO schema_migrations (version) VALUES ('20151120090455'); + +INSERT INTO schema_migrations (version) VALUES ('20151124200353'); + +INSERT INTO schema_migrations (version) VALUES ('20151125155601'); + +INSERT INTO schema_migrations (version) VALUES ('20151127091716'); + +INSERT INTO schema_migrations (version) VALUES ('20151130175654'); + +INSERT INTO schema_migrations (version) VALUES ('20151202123506'); + +INSERT INTO schema_migrations (version) VALUES ('20160106092052'); + +INSERT INTO schema_migrations (version) VALUES ('20160108135436'); + diff --git a/lib/schemas/ariport.wsdl b/lib/schemas/ariport.wsdl new file mode 100644 index 000000000..7525c9227 --- /dev/null +++ b/lib/schemas/ariport.wsdl @@ -0,0 +1,510 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Teenuste nimekiri + + + + + + + Adapteri test + + + + + + + Ettevõtjaga seotud dokumentide loetelu päring + + + + + + + Ettevõtja esmakannete päring + + + + + + + Ettevõtja muudatuste loetelu tasuline päring + + + + + + + Ettevotja rekvisiitide päring + + + + + + + Ettevotja rekvisiitide fail + + + + + + + Isikute otsing + + + + + + + Klassifikaatorite päring + + + + + + + Ettevõtja majandusaasta aruande päring + + + + + + + Ettevõtja majandusaasta aruande loetelu päring + + + + + + + Ettevõtja detailandmete päring v5 + + + + + + + E-notar: toimiku dokumendi sisu + + + + + + + Ettevõtja lihtandmete päring v5 + + + + + + + Ettevõtja lihtandmete päring tasuta + + + + + + + Esindusõiguste päring v3 + + + + + + + Esindusõiguste päring v4 + + + + + + + Visuaalse Äriregistri ettevõtete-isikute vaheliste seoste päring + + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + + + + + Äriregister_uus + + + + diff --git a/lib/schemas/testariport.wsdl b/lib/schemas/testariport.wsdl new file mode 100644 index 000000000..25e3818b2 --- /dev/null +++ b/lib/schemas/testariport.wsdl @@ -0,0 +1,510 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Teenuste nimekiri + + + + + + + Adapteri test + + + + + + + Ettevõtjaga seotud dokumentide loetelu päring + + + + + + + Ettevõtja esmakannete päring + + + + + + + Ettevõtja muudatuste loetelu tasuline päring + + + + + + + Ettevotja rekvisiitide päring + + + + + + + Ettevotja rekvisiitide fail + + + + + + + Isikute otsing + + + + + + + Klassifikaatorite päring + + + + + + + Ettevõtja majandusaasta aruande päring + + + + + + + Ettevõtja majandusaasta aruande loetelu päring + + + + + + + Ettevõtja detailandmete päring v5 + + + + + + + E-notar: toimiku dokumendi sisu + + + + + + + Ettevõtja lihtandmete päring v5 + + + + + + + Ettevõtja lihtandmete päring tasuta + + + + + + + Esindusõiguste päring v3 + + + + + + + Esindusõiguste päring v4 + + + + + + + Visuaalse Äriregistri ettevõtete-isikute vaheliste seoste päring + + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + v1 + + + + + + + + + + + + + + Äriregister_uus + + + + diff --git a/lib/tasks/epp.rake b/lib/tasks/epp.rake new file mode 100644 index 000000000..e03835dad --- /dev/null +++ b/lib/tasks/epp.rake @@ -0,0 +1,19 @@ +namespace :epp do + + desc 'EPP actions' + task all: :environment do + Rake::Task['epp:trim_documents'].invoke + end + + desc 'Trim logs' + task trim_documents: :environment do + puts '-----> Running query' + sql = <<-SQL + UPDATE epp_logs SET request = regexp_replace(request, '', '[FILTERED]<\eis:legalDocument>'); + SQL + ApiLog::EppLog.connection.execute(sql) + + puts "-----> Query done" + end +end + diff --git a/lib/tasks/whois.rake b/lib/tasks/whois.rake index fd905e383..c8c3ba2a1 100644 --- a/lib/tasks/whois.rake +++ b/lib/tasks/whois.rake @@ -3,15 +3,24 @@ namespace :whois do task regenerate: :environment do start = Time.zone.now.to_f - @i = 0 print "-----> Regenerate Registry whois_records table and sync with whois server..." ActiveRecord::Base.uncached do - puts "\n#{@i}" - Domain.included.find_in_batches(batch_size: 10000) do |batch| - batch.map(&:update_whois_record) - puts(@i += 10000) - GC.start + + print "\n-----> Update domains whois_records" + Domain.find_in_batches.each do |group| + UpdateWhoisRecordJob.enqueue group.map(&:id), 'domain' end + + print "\n-----> Update blocked domains whois_records" + BlockedDomain.find_in_batches.each do |group| + UpdateWhoisRecordJob.enqueue group.map(&:id), 'blocked' + end + + print "\n-----> Update reserved domains whois_records" + ReservedDomain.find_in_batches.each do |group| + UpdateWhoisRecordJob.enqueue group.map(&:id), 'reserved' + end + end puts "\n-----> all done in #{(Time.zone.now.to_f - start).round(2)} seconds" end diff --git a/spec/models/directo_spec.rb b/spec/models/directo_spec.rb new file mode 100644 index 000000000..bf187d2bf --- /dev/null +++ b/spec/models/directo_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Directo, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/domain_spec.rb b/spec/models/domain_spec.rb index 9dd0f1a48..cddb9141b 100644 --- a/spec/models/domain_spec.rb +++ b/spec/models/domain_spec.rb @@ -140,20 +140,20 @@ describe Domain do domain.registrant_verification_asked_at = 30.days.ago domain.pending_delete! - Domain.clean_expired_pendings.should == 1 + DomainCron.clean_expired_pendings.should == 1 domain.reload.pending_delete?.should == false domain.pending_json.should == {} end it 'should expire domains' do - Domain.start_expire_period + DomainCron.start_expire_period @domain.statuses.include?(DomainStatus::EXPIRED).should == false old_valid_to = Time.zone.now - 10.days @domain.valid_to = old_valid_to @domain.save - Domain.start_expire_period + DomainCron.start_expire_period @domain.reload @domain.statuses.include?(DomainStatus::EXPIRED).should == true @domain.outzone_at.should be_within(5).of(old_valid_to + Setting.expire_warning_period.days) @@ -161,7 +161,7 @@ describe Domain do old_valid_to + Setting.expire_warning_period.days + Setting.redemption_grace_period.days ) - Domain.start_expire_period + DomainCron.start_expire_period @domain.reload @domain.statuses.include?(DomainStatus::EXPIRED).should == true end @@ -173,7 +173,7 @@ describe Domain do @domain.outzone_at, @domain.delete_at = nil, nil @domain.save - Domain.start_expire_period + DomainCron.start_expire_period @domain.reload @domain.statuses.include?(DomainStatus::EXPIRED).should == true @domain.outzone_at.should be_within(5).of(old_valid_to + Setting.expire_warning_period.days) @@ -183,7 +183,7 @@ describe Domain do end it 'should start redemption grace period' do - Domain.start_redemption_grace_period + DomainCron.start_redemption_grace_period @domain.reload @domain.statuses.include?(DomainStatus::SERVER_HOLD).should == false @@ -191,20 +191,20 @@ describe Domain do @domain.statuses << DomainStatus::SERVER_MANUAL_INZONE # this prohibits server_hold @domain.save - Domain.start_redemption_grace_period + DomainCron.start_redemption_grace_period @domain.reload @domain.statuses.include?(DomainStatus::SERVER_HOLD).should == false @domain.statuses = [] @domain.save - Domain.start_redemption_grace_period + DomainCron.start_redemption_grace_period @domain.reload @domain.statuses.include?(DomainStatus::SERVER_HOLD).should == true end it 'should start delete period' do - Domain.start_delete_period + DomainCron.start_delete_period @domain.reload @domain.statuses.include?(DomainStatus::DELETE_CANDIDATE).should == false @@ -212,13 +212,13 @@ describe Domain do @domain.statuses << DomainStatus::SERVER_DELETE_PROHIBITED # this prohibits delete_candidate @domain.save - Domain.start_delete_period + DomainCron.start_delete_period @domain.reload @domain.statuses.include?(DomainStatus::DELETE_CANDIDATE).should == false @domain.statuses = [] @domain.save - Domain.start_delete_period + DomainCron.start_delete_period @domain.reload @domain.statuses.include?(DomainStatus::DELETE_CANDIDATE).should == true @@ -234,7 +234,7 @@ describe Domain do Domain.count.should == 2 - Domain.start_delete_period + DomainCron.start_delete_period Domain.destroy_delete_candidates Domain.count.should == 0 @@ -391,7 +391,7 @@ describe Domain do end it 'should start redemption grace period' do - Domain.start_redemption_grace_period + DomainCron.start_redemption_grace_period @domain.reload @domain.statuses.include?(DomainStatus::SERVER_HOLD).should == false @@ -399,14 +399,14 @@ describe Domain do @domain.statuses << DomainStatus::SERVER_MANUAL_INZONE # this prohibits server_hold @domain.save - Domain.start_redemption_grace_period + DomainCron.start_redemption_grace_period @domain.reload @domain.statuses.include?(DomainStatus::SERVER_HOLD).should == false @domain.statuses = [] @domain.save - Domain.start_redemption_grace_period + DomainCron.start_redemption_grace_period @domain.reload @domain.statuses.include?(DomainStatus::SERVER_HOLD).should == true end