diff --git a/CHANGELOG.md b/CHANGELOG.md index c78017d2a..670d5392d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +15.04.2015 + +* Added whois tasks, more info with rake -T whois + 02.04.2015 * Depricated DelayedJob, kill all running delayed jobs if needed diff --git a/app/assets/stylesheets/registrar.sass b/app/assets/stylesheets/registrar.sass index 0ab63cacb..005bde52a 100644 --- a/app/assets/stylesheets/registrar.sass +++ b/app/assets/stylesheets/registrar.sass @@ -42,3 +42,6 @@ hr background: image_url('bg.jpg') color: white !important background-size: 100% + +.semifooter + padding: 42px 0 80px 0 diff --git a/app/models/domain.rb b/app/models/domain.rb index d6aa28718..64413bd6c 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -53,6 +53,7 @@ class Domain < ActiveRecord::Base end after_save :manage_automatic_statuses after_save :update_whois_body + after_save :update_whois_server validates :name_dirty, domain_name: true, uniqueness: true validates :period, numericality: { only_integer: true } @@ -118,6 +119,15 @@ class Domain < ActiveRecord::Base return period.to_i.months if unit == 'm' return period.to_i.years if unit == 'y' end + + def included + includes( + :registrar, + :nameservers, + { tech_contacts: :registrar }, + { admin_contacts: :registrar } + ) + end end def name=(value) @@ -228,12 +238,6 @@ class Domain < ActiveRecord::Base log end - def update_whois_server - wd = Whois::Domain.find_or_initialize_by(name: name) - wd.whois_body = whois_body - wd.save - end - # rubocop:disable Metrics/MethodLength def update_whois_body self.whois_body = <<-EOS @@ -260,14 +264,12 @@ class Domain < ActiveRecord::Base created: #{registrar.created_at.to_s(:db)} changed: #{registrar.updated_at.to_s(:db)} EOS - - update_whois_server end # rubocop:enable Metrics/MethodLength def contacts_body out = '' - admin_contacts.includes(:registrar).each do |c| + admin_contacts.each do |c| out << 'Admin contact:' out << "name: #{c.name}" out << "email: #{c.email}" @@ -275,7 +277,7 @@ class Domain < ActiveRecord::Base out << "created: #{c.created_at.to_s(:db)}" end - tech_contacts.includes(:registrar).each do |c| + tech_contacts.each do |c| out << 'Tech contact:' out << "name: #{c.name}" out << "email: #{c.email}" @@ -284,4 +286,10 @@ class Domain < ActiveRecord::Base end out end + + def update_whois_server + wd = Whois::Domain.find_or_initialize_by(name: name) + wd.whois_body = whois_body + wd.save + end end diff --git a/app/views/layouts/application.haml b/app/views/layouts/application.haml index 73c55c1d7..fafc5ef19 100644 --- a/app/views/layouts/application.haml +++ b/app/views/layouts/application.haml @@ -42,7 +42,7 @@ = t('settings') %span.caret %ul.dropdown-menu{role: "menu"} - %li.dropdown-header= t('accounting') + %li.dropdown-header= t('billing') %li= link_to t('bank_statements'), admin_bank_statements_path %li.divider %li.dropdown-header= t('system') diff --git a/app/views/layouts/registrar/application.haml b/app/views/layouts/registrar/application.haml index 85e10adeb..4eec521ba 100644 --- a/app/views/layouts/registrar/application.haml +++ b/app/views/layouts/registrar/application.haml @@ -39,7 +39,7 @@ - if can? :show, Invoice - active_class = ['registrar/invoices'].include?(params[:controller]) ? 'active' :nil - %li{class: active_class}= link_to t('accounting'), registrar_invoices_path + %li{class: active_class}= link_to t('billing'), registrar_invoices_path - if can? :view, :registrar_xml_console - active_class = ['registrar/xml_consoles'].include?(params[:controller]) ? 'active' :nil diff --git a/app/views/registrar/invoices/show.haml b/app/views/registrar/invoices/show.haml index 84d26942e..bebe999f1 100644 --- a/app/views/registrar/invoices/show.haml +++ b/app/views/registrar/invoices/show.haml @@ -4,13 +4,14 @@ = t('invoice_no', no: @invoice.id) .col-sm-6 %h1.text-right.text-center-xs - = link_to(t('back_to_accounting'), registrar_invoices_path, class: 'btn btn-default') + = link_to(t('back_to_billing'), registrar_invoices_path, class: 'btn btn-default') %hr .row - .col-md-6= render 'registrar/invoices/partials/banklinks' .col-md-6= render 'registrar/invoices/partials/details' .row .col-md-6= render 'registrar/invoices/partials/seller' .col-md-6= render 'registrar/invoices/partials/buyer' .row .col-md-12= render 'registrar/invoices/partials/items' +.row.semifooter + .col-md-12.text-right= render 'registrar/invoices/partials/banklinks' diff --git a/config/locales/en.yml b/config/locales/en.yml index 141a67d64..8f9510335 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -653,10 +653,9 @@ en: vat: 'VAT (%{vat_prc}%)' unpaid: 'Unpaid' your_current_credit_account_balance_is: 'Your current credit account balance is %{balance} EUR' - accounting: 'Accounting' + billing: 'Billing' your_account: 'Your account' pay_by_bank_link: 'Pay by bank link' - back_to_accounting: 'Back to accounting' issue_date: 'Issue date' due_date: 'Due date' payment_term: 'Payment term' @@ -676,6 +675,7 @@ en: import_th6_bank_statement: 'Import TH6 bank statement' back_to_bank_statements: 'Back to bank statements' back_to_bank_statement: 'Back to bank statement' + back_to_billing: 'Back to billing' imported_at: 'Imported at' bank_statement: 'Bank statement' bank_transactions: 'Bank transactions' diff --git a/db/migrate/20150414151357_data_update.rb b/db/migrate/20150414151357_data_update.rb new file mode 100644 index 000000000..49cf38901 --- /dev/null +++ b/db/migrate/20150414151357_data_update.rb @@ -0,0 +1,17 @@ +class DataUpdate < ActiveRecord::Migration + def change + Registrar.where( + name: 'EIS', + reg_no: '90010019', + phone: '+372 727 1000', + country_code: 'EE', + vat_no: 'EE101286464', + email: 'info@internet.ee', + state: 'Harjumaa', + city: 'Tallinn', + street: 'Paldiski mnt 80', + zip: '10617', + url: 'www.internet.ee' + ).first_or_create! + end +end diff --git a/lib/tasks/whois.rake b/lib/tasks/whois.rake new file mode 100644 index 000000000..29d15fcb8 --- /dev/null +++ b/lib/tasks/whois.rake @@ -0,0 +1,33 @@ +namespace :whois do + desc 'Delete whois database data and import all from Registry (fast)' + task reset: :environment do + start = Time.zone.now.to_f + print "-----> Reset whois database and sync..." + domains = Domain.pluck(:name, :whois_body) + Whois::Domain.delete_all + Whois::Domain.import([:name, :whois_body], domains) + puts "\n-----> all done in #{(Time.zone.now.to_f - start).round(2)} seconds" + end + + desc 'Sync whois database without reset (slow)' + task sync: :environment do + start = Time.zone.now.to_f + print "-----> Sync whois database..." + Domain.select(:id, :name, :whois_body).find_each(batch_size: 100000).with_index do |d, index| + d.update_whois_server + print '.' if index % 100 == 0 + end + puts "\n-----> all done in #{(Time.zone.now.to_f - start).round(2)} seconds" + end + + desc 'Regenerate whois_body at Registry master database (slow)' + task generate: :environment do + start = Time.zone.now.to_f + print "-----> Update Registry records..." + Domain.included.find_each(batch_size: 100000).with_index do |d, index| + d.update_columns(whois_body: d.update_whois_body) + print '.' if index % 100 == 0 + end + puts "\n-----> all done in #{(Time.zone.now.to_f - start).round(2)} seconds" + end +end