From fc1aa47411ef88f48872e63f3ef3d809a13cd7b1 Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Mon, 10 Aug 2015 21:48:17 +0300 Subject: [PATCH 1/7] Updated example files for easier setup/testing #2557 --- config/application-example.yml | 108 +++++++++++++++++++++++---------- 1 file changed, 76 insertions(+), 32 deletions(-) diff --git a/config/application-example.yml b/config/application-example.yml index 5cba1c9b2..a3a4d2cc0 100644 --- a/config/application-example.yml +++ b/config/application-example.yml @@ -1,30 +1,47 @@ +# +# Registry servers configuration +# +# # Be sure to restart your server when you modify settings. +# +# +# SMTP configuration (for Admin/EPP/Registrar/Registrant servers) +# +smtp_address: 'server-hostname' +smtp_port: '25' # 587, 465 +smtp_user_name: 'login' +smtp_password: 'pw/key' +# If you need to specify a HELO domain, you can do it here. +smtp_domain: '' # 'domain for HELO checking' +# Use "none" only when for a self-signed and/or wildcard certificate +smtp_openssl_verify_mode: 'peer' # 'none', 'peer', 'client_once','fail_if_no_peer_cert' +# Detects if STARTTLS is enabled in your SMTP server and starts to use it. Defaults to true. +# Set this to false if there is a problem with your server certificate that you cannot resolve. +smtp_enable_starttls_auto: 'true' # 'false' +# If your mail server requires authentication, please change. +smtp_authentication: 'plain' # 'plain', 'login', 'cram_md5' +registrant_url: 'https:/registrant.example.com' # for valid email body registrant links + +# +# ADMIN server +# app_name: '.EE Registry' zonefile_export_dir: 'export/zonefiles' bank_statement_import_dir: 'import/bank_statements' legal_documents_dir: 'import/legal_documents' time_zone: 'Tallinn' # more zones by rake time:zones:all -# New Relic app name, keep only current mode, remove other names. -# Example: 'Admin, EPP, REPP' will have name 'Admin, EPP, REPP - production' at New Relic. -new_relic_app_name: 'Admin, EPP, REPP, Registrar, Registrant' -new_relic_license_key: '42d1c2ba4ed17a9cf6297c59d80e563a3dd3c4fa' - -# You can use `rake secret` to generate a secure secret key. -# Your secret key is used for verifying the integrity of signed cookies. -# If you change this key, all old signed cookies will become invalid! -secret_key_base: 'please-change-it-you-can-generate-it-with-rake-secret' -devise_secret: 'please-change-it-you-can-generate-it-with-rake-secret' - -# Admin server configuration: openssl_config_path: '/etc/ssl/openssl.cnf' crl_dir: '/home/registry/registry/shared/ca/crl' 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' -# EPP server configuration + +# +# EPP +# webclient_ips: '127.0.0.1,0.0.0.0' #ips, separated with commas webclient_cert_common_name: 'webclient' # Contact epp will not accept org value by default @@ -41,7 +58,10 @@ contact_org_enabled: 'false' # Custom legal document types # legal_document_types: "pdf,bdoc,ddoc,zip,rar,gz,tar,7z,odt,doc,docx" -# DEPP server configuration (both for Registrar/Registrant servers) + +# +# REGISTRAR configuration (DEPP) +# show_ds_data_fields: 'false' default_nameservers_count: '2' default_admin_contacts_count: '1' @@ -51,30 +71,40 @@ key_path: '/home/registry/registry/shared/ca/private/webclient.key.pem' epp_hostname: 'registry.gitlab.eu' repp_url: 'https://repp.gitlab.eu/repp/v1/' -# Registrant server configuration + +# +# REGISTRANT configuration +# restful_whois_url: 'https://restful-whois.example.com' -# SMTP configuration (for Admin/EPP/Registrar/Registrant servers) -smtp_address: 'server-hostname' -smtp_port: '25' # 587, 465 -smtp_user_name: 'login' -smtp_password: 'pw/key' -# If you need to specify a HELO domain, you can do it here. -smtp_domain: '' # 'domain for HELO checking' -# Use "none" only when for a self-signed and/or wildcard certificate -smtp_openssl_verify_mode: 'peer' # 'none', 'peer', 'client_once','fail_if_no_peer_cert' -# Detects if STARTTLS is enabled in your SMTP server and starts to use it. Defaults to true. -# Set this to false if there is a problem with your server certificate that you cannot resolve. -smtp_enable_starttls_auto: 'true' # 'false' -# If your mail server requires authentication, please change. -smtp_authentication: 'plain' # 'plain', 'login', 'cram_md5' -registrant_url: 'https:/registrant.example.com' # for valid email body registrant links + +# +# REGISTRAR AND REGISTRANT +# # SK DigiDocService sk_digi_doc_service_endpoint: 'https://openxades.org:9443/DigiDocService' sk_digi_doc_service_name: 'EIS test' -# Autotest config overwrites + +# +# MISC +# +# New Relic app name, keep only current mode, remove other names. +# Example: 'Admin, EPP, REPP' will have name 'Admin, EPP, REPP - production' at New Relic. +new_relic_app_name: 'Admin, EPP, REPP, Registrar, Registrant' +new_relic_license_key: '42d1c2ba4ed17a9cf6297c59d80e563a3dd3c4fa' + +# You can use `rake secret` to generate a secure secret key. +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! +secret_key_base: 'please-change-it-you-can-generate-it-with-rake-secret' +devise_secret: 'please-change-it-you-can-generate-it-with-rake-secret' + + +# +# AUTOTEST overwrites +# test: webclient_ips: '127.0.0.1' # it should match to localhost ip address crl_dir: '/var/lib/jenkins/workspace/registry/ca/crl' @@ -84,7 +114,21 @@ test: ca_key_password: 'test' cert_path: '/var/lib/jenkins/workspace/registry/ca/certs/webclient.crt.pem' - # DEPP + # Registrar/DEPP key_path: '/var/lib/jenkins/workspace/registry/ca/private/webclient.key.pem' epp_hostname: '127.0.0.1' repp_url: 'http://127.0.0.1:8989/repp/v1/' + + +# +# DEVELOPMENT overwrites +# +development: + epp_hostname: '127.0.0.1' + repp_url: 'http://127.0.0.1:8080/repp/v1/' + cert_path: 'ca/certs/webclient.cert.pem' + key_path: 'ca/private/webclient.key.pem' + crl_dir: 'ca/crl' + ca_cert_path: 'ca/certs/ca.crt.pem' + ca_key_path: 'ca/private/ca.key.pem' + ca_key_password: 'your-root-key-password' From d8125ebea4b9e60090d6b67cf5134ebd9409fb8a Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Mon, 10 Aug 2015 22:01:26 +0300 Subject: [PATCH 2/7] Registrant new contact ident changable when not yet valid --- app/views/registrar/contacts/form_partials/_general.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/registrar/contacts/form_partials/_general.haml b/app/views/registrar/contacts/form_partials/_general.haml index 24e02e435..6d7f2845f 100644 --- a/app/views/registrar/contacts/form_partials/_general.haml +++ b/app/views/registrar/contacts/form_partials/_general.haml @@ -33,7 +33,7 @@ .col-md-3.control-label = f.label :ident, t(:ident) + '*' .col-md-7 - - if f.object.ident.present? + - if @contact.persisted? && f.object.ident.present? .disabled-value = f.object.ident - else From f5311301c9c7cf72c7ed8bb744d5914079ef1393 Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Mon, 10 Aug 2015 22:23:58 +0300 Subject: [PATCH 3/7] Registrant: remember invalid contact values --- app/views/registrar/contacts/form_partials/_general.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/registrar/contacts/form_partials/_general.haml b/app/views/registrar/contacts/form_partials/_general.haml index 6d7f2845f..9ef12d8f1 100644 --- a/app/views/registrar/contacts/form_partials/_general.haml +++ b/app/views/registrar/contacts/form_partials/_general.haml @@ -11,7 +11,7 @@ = Country.new(f.object.ident_country_code).try(:to_s) = " [#{f.object.ident_country_code}]" - else - - country_selected = @contact.persisted? ? '' : 'EE' + - country_selected = @contact.persisted? ? '' : (params[:depp_contact].try(:[], :ident_country_code) || 'EE') = f.select(:ident_country_code, SortedCountry.all_options(country_selected), {}, class: 'js-ident-country-code', required: true) @@ -24,7 +24,7 @@ = Depp::Contact.type_string(f.object.ident_type) = " [#{f.object.ident_type}]" - else - - type_selected = @contact.persisted? ? '' : 'bic' + - type_selected = @contact.persisted? ? '' : (params[:depp_contact].try(:[], :ident_type) || 'bic') = f.select(:ident_type, Depp::Contact::SELECTION_TYPES, { selected: type_selected }, class: 'js-ident-type', required: true) From e9cf3d2fbe3cbbdcfaa813c658163a54939d900f Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Mon, 10 Aug 2015 20:04:20 +0300 Subject: [PATCH 4/7] Added comma support #2785 --- .../admin/bank_transactions_controller.rb | 2 + .../admin/pricelists_controller.rb | 3 ++ app/controllers/application_controller.rb | 6 +++ app/helpers/application_helper.rb | 5 +++ app/models/deposit.rb | 4 ++ app/views/admin/bank_statements/show.haml | 2 +- app/views/admin/bank_transactions/_form.haml | 2 +- app/views/admin/bank_transactions/show.haml | 2 +- app/views/admin/pricelists/_form.haml | 2 +- app/views/admin/pricelists/index.haml | 2 +- .../registrar/invoices/partials/_items.haml | 12 +++--- app/views/registrar/invoices/pdf.haml | 12 +++--- spec/features/admin/bank_statement_spec.rb | 2 +- spec/features/admin/invoice_spec.rb | 6 +-- spec/models/deposit_spec.rb | 39 +++++++++++++++++++ 15 files changed, 80 insertions(+), 21 deletions(-) create mode 100644 spec/models/deposit_spec.rb diff --git a/app/controllers/admin/bank_transactions_controller.rb b/app/controllers/admin/bank_transactions_controller.rb index 1aaf452a8..7fbdb6ad1 100644 --- a/app/controllers/admin/bank_transactions_controller.rb +++ b/app/controllers/admin/bank_transactions_controller.rb @@ -7,6 +7,7 @@ class Admin::BankTransactionsController < AdminController end def create + comma_support_for(:bank_transaction, :sum) @bank_transaction = BankTransaction.new( bank_transaction_params.merge(bank_statement_id: params[:bank_statement_id]) ) @@ -21,6 +22,7 @@ class Admin::BankTransactionsController < AdminController end def update + comma_support_for(:bank_transaction, :sum) if @bank_transaction.update(bank_transaction_params) flash[:notice] = I18n.t('record_updated') redirect_to [:admin, @bank_transaction] diff --git a/app/controllers/admin/pricelists_controller.rb b/app/controllers/admin/pricelists_controller.rb index 8037f57f6..ce1431ab0 100644 --- a/app/controllers/admin/pricelists_controller.rb +++ b/app/controllers/admin/pricelists_controller.rb @@ -17,6 +17,7 @@ class Admin::PricelistsController < AdminController end def create + comma_support_for(:pricelist, :price) @pricelist = Pricelist.new(pricelist_params) if @pricelist.save @@ -27,6 +28,7 @@ class Admin::PricelistsController < AdminController end def update + comma_support_for(:pricelist, :price) if @pricelist.update_attributes(pricelist_params) redirect_to admin_pricelists_url else @@ -49,4 +51,5 @@ class Admin::PricelistsController < AdminController params.require(:pricelist).permit(:operation_category, :category, :price_category, :duration, :price, :valid_from, :valid_to) end + end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 87099d6fa..318923e3d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -70,4 +70,10 @@ class ApplicationController < ActionController::Base return 'public' if user.nil? "#{user.id}-#{user.class}: #{user.username}" end + + def comma_support_for(parent_key, key) + return if params[parent_key].blank? + return if params[parent_key][key].blank? + params[parent_key][key].sub!(/,/, '.') + end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7397ec7cb..4efb6f2ee 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -45,4 +45,9 @@ module ApplicationHelper # can be api user or some other user link_to(model.updator, ['admin', model.updator]) end + + def currency(amount) + amount ||= 0 + ("%01.2f" % amount.round(2)).sub(/\./, ',') + end end diff --git a/app/models/deposit.rb b/app/models/deposit.rb index f9f887af1..23045196a 100644 --- a/app/models/deposit.rb +++ b/app/models/deposit.rb @@ -23,6 +23,10 @@ class Deposit false end + def amount + BigDecimal.new(@amount.to_s.sub(/,/, '.')) + end + def issue_prepayment_invoice valid? && registrar.issue_prepayment_invoice(amount, description) end diff --git a/app/views/admin/bank_statements/show.haml b/app/views/admin/bank_statements/show.haml index db8d64004..9797c59bf 100644 --- a/app/views/admin/bank_statements/show.haml +++ b/app/views/admin/bank_statements/show.haml @@ -63,7 +63,7 @@ %tr %td= link_to(l(x.paid_at, format: :date_long), [:admin, x]) %td= x.buyer_name - %td= x.sum + %td= currency(x.sum) %td= x.currency - c = x.binded? ? 'text-success' : 'text-danger' %td{class: c}= x.binded? ? t(:binded) : t(:not_binded) diff --git a/app/views/admin/bank_transactions/_form.haml b/app/views/admin/bank_transactions/_form.haml index 244284fda..b8c63c166 100644 --- a/app/views/admin/bank_transactions/_form.haml +++ b/app/views/admin/bank_transactions/_form.haml @@ -18,7 +18,7 @@ .form-group = f.label :sum, class: 'col-md-4 control-label required' .col-md-8 - = f.text_field(:sum, class: 'form-control', required: true) + = f.text_field(:sum, value: currency(f.object.sum), class: 'form-control', required: true) .form-group = f.label :reference_no, class: 'col-md-4 control-label required' diff --git a/app/views/admin/bank_transactions/show.haml b/app/views/admin/bank_transactions/show.haml index 7bcd8cfa1..4133386e5 100644 --- a/app/views/admin/bank_transactions/show.haml +++ b/app/views/admin/bank_transactions/show.haml @@ -36,7 +36,7 @@ %dd= @bank_transaction.description %dt= t(:sum) - %dd= @bank_transaction.sum + %dd= currency(@bank_transaction.sum) %dt= t(:currency) %dd= @bank_transaction.currency diff --git a/app/views/admin/pricelists/_form.haml b/app/views/admin/pricelists/_form.haml index 9e1715e72..a751825ca 100644 --- a/app/views/admin/pricelists/_form.haml +++ b/app/views/admin/pricelists/_form.haml @@ -15,7 +15,7 @@ .form-group = f.label :price .input-group - = f.text_field(:price, class: 'form-control') + = f.text_field(:price, value: currency(f.object.price), class: 'form-control') %span.input-group-addon= Money.default_currency .form-group.input-daterange = f.label :valid_from, t(:valid) diff --git a/app/views/admin/pricelists/index.haml b/app/views/admin/pricelists/index.haml index 2f51a4329..50edcff2e 100644 --- a/app/views/admin/pricelists/index.haml +++ b/app/views/admin/pricelists/index.haml @@ -33,7 +33,7 @@ %td= pricelist.category %td= pricelist.duration %td= pricelist.operation_category - %td= pricelist.price + %td= currency(pricelist.price) %td= l(pricelist.valid_from, format: :ydate) %td= l(pricelist.valid_to, format: :ydate) %td= link_to(t(:edit), edit_admin_pricelist_path(pricelist), class: 'btn btn-xs btn-primary') diff --git a/app/views/registrar/invoices/partials/_items.haml b/app/views/registrar/invoices/partials/_items.haml index 784fe4412..6ed5144a8 100644 --- a/app/views/registrar/invoices/partials/_items.haml +++ b/app/views/registrar/invoices/partials/_items.haml @@ -14,19 +14,19 @@ %tr %td= t(x.description) %td= x.unit - %td= x.amount - %td= x.price - %td= x.item_sum_without_vat + %td= currency(x.amount) + %td= currency(x.price) + %td= currency(x.item_sum_without_vat) %tfoot %tr %th{colspan: 3} %th= t(:total_without_vat) - %td= @invoice.sum_without_vat + %td= currency(@invoice.sum_without_vat) %tr %th.no-border{colspan: 3} %th= t('vat', vat_prc: (@invoice.vat_prc * 100).round) - %td= @invoice.vat + %td= currency(@invoice.vat) %tr %th.no-border{colspan: 3} %th= t(:total) - %td= @invoice.sum + %td= currency(@invoice.sum) diff --git a/app/views/registrar/invoices/pdf.haml b/app/views/registrar/invoices/pdf.haml index ae67ac4e3..d90c24fec 100644 --- a/app/views/registrar/invoices/pdf.haml +++ b/app/views/registrar/invoices/pdf.haml @@ -229,22 +229,22 @@ %tr %td= t(x.description) %td= x.unit - %td= x.amount - %td= x.price - %td= "#{x.item_sum_without_vat} #{@invoice.currency}" + %td= currency(x.amount) + %td= currency(x.price) + %td= "#{currency(x.item_sum_without_vat)} #{@invoice.currency}" %tfoot %tr %th{colspan: 3} %th= t(:total_without_vat) - %td= "#{@invoice.sum_without_vat} #{@invoice.currency}" + %td= "#{currency(@invoice.sum_without_vat)} #{@invoice.currency}" %tr %th.no-border{colspan: 3} %th= t('vat', vat_prc: (@invoice.vat_prc * 100).round) - %td= "#{@invoice.vat} #{@invoice.currency}" + %td= "#{currency(@invoice.vat)} #{@invoice.currency}" %tr %th.no-border{colspan: 3} %th= t(:total) - %td= "#{@invoice.sum} #{@invoice.currency}" + %td= "#{currency(@invoice.sum)} #{@invoice.currency}" #footer %hr diff --git a/spec/features/admin/bank_statement_spec.rb b/spec/features/admin/bank_statement_spec.rb index bca3136fb..b6ac8dcd2 100644 --- a/spec/features/admin/bank_statement_spec.rb +++ b/spec/features/admin/bank_statement_spec.rb @@ -46,7 +46,7 @@ feature 'BankStatement', type: :feature do click_link 'Back to bank statement' - page.should have_content('120.0') + page.should have_content('120,00') page.should have_content('Test buyer') end end diff --git a/spec/features/admin/invoice_spec.rb b/spec/features/admin/invoice_spec.rb index e036b5f1c..1e10f066b 100644 --- a/spec/features/admin/invoice_spec.rb +++ b/spec/features/admin/invoice_spec.rb @@ -37,7 +37,7 @@ feature 'Invoice', type: :feature do page.should have_content('Record created') page.should have_content('Invoice no.') page.should have_content('Prepayment') - page.should have_content('120.0') + page.should have_content('120,00') page.should have_content(r.name) end @@ -107,7 +107,7 @@ feature 'Invoice', type: :feature do page.should have_content('689') page.should have_content('EE557700771000598731') page.should have_content('Not binded', count: 2) - page.should have_content(invoice.sum.to_s) + page.should have_content('240,00') page.should have_content('EUR') click_link 'Bind invoices' @@ -120,7 +120,7 @@ feature 'Invoice', type: :feature do page.should have_content('Binded') page.should have_content(invoice.to_s) - page.should have_content(invoice.sum.to_s) + page.should have_content('240,00') page.should have_content(invoice.reference_no) page.should have_content(I18n.l(paid_at, format: :date_long)) diff --git a/spec/models/deposit_spec.rb b/spec/models/deposit_spec.rb new file mode 100644 index 000000000..ff77dbd98 --- /dev/null +++ b/spec/models/deposit_spec.rb @@ -0,0 +1,39 @@ +require 'rails_helper' + +describe Deposit do + context 'with invalid attribute' do + before :all do + @deposit = Deposit.new + end + + it 'should not be valid' do + @deposit.valid? + @deposit.errors.full_messages.should match_array([ + "Registrar is missing" + ]) + end + + it 'should have 0 amount' do + @deposit.amount.should == 0 + end + + it 'should not be presisted' do + @deposit.persisted?.should == false + end + + it 'should replace comma with point for 0' do + @deposit.amount = '0,0' + @deposit.amount.should == 0.0 + end + + it 'should replace comma with points' do + @deposit.amount = '10,11' + @deposit.amount.should == 10.11 + end + + it 'should work with float as well' do + @deposit.amount = 0.123 + @deposit.amount.should == 0.123 + end + end +end From e988bb6a2096c10836dd0b3651177622ca9e6853 Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Mon, 10 Aug 2015 23:33:09 +0300 Subject: [PATCH 5/7] Pending delete or update added to domain log view #2785 --- .../admin/domain_versions_controller.rb | 6 +++ app/helpers/application_helper.rb | 5 +++ app/views/admin/domain_versions/_version.haml | 37 +++++++++++++++---- app/views/admin/domain_versions/index.haml | 5 +++ .../admin/domains/partials/_statuses.haml | 8 +++- 5 files changed, 51 insertions(+), 10 deletions(-) diff --git a/app/controllers/admin/domain_versions_controller.rb b/app/controllers/admin/domain_versions_controller.rb index 981783e20..9700e26c1 100644 --- a/app/controllers/admin/domain_versions_controller.rb +++ b/app/controllers/admin/domain_versions_controller.rb @@ -4,6 +4,12 @@ class Admin::DomainVersionsController < AdminController def index @domain = Domain.find(params[:domain_id]) @versions = @domain.versions + + if @domain.pending_json.present? + frame = Nokogiri::XML(@domain.pending_json['frame']) + @pending_user = User.find(@domain.pending_json['current_user_id']) + @pending_domain = Epp::Domain.new_from_epp(frame, @pending_user) + end end # def index diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4efb6f2ee..6ab5fe4e8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -50,4 +50,9 @@ module ApplicationHelper amount ||= 0 ("%01.2f" % amount.round(2)).sub(/\./, ',') end + + def plain_username(username) + username ||= '' + username.split(':').last.to_s.strip + end end diff --git a/app/views/admin/domain_versions/_version.haml b/app/views/admin/domain_versions/_version.haml index c8bef118b..3c8b87ff2 100644 --- a/app/views/admin/domain_versions/_version.haml +++ b/app/views/admin/domain_versions/_version.haml @@ -1,16 +1,37 @@ -- if version.present? && domain.present? - - children = HashWithIndifferentAccess.new(version.children) - - nameservers = children[:nameservers] || [] - - tech_contacts = children[:tech_contacts] || [] - - admin_contacts = children[:admin_contacts] || [] - - registrant = children[:registrant] || [] +- version ||= false +- domain ||= false +- pending_user ||= false + +- if domain.present? + - if version # normal history + - children = HashWithIndifferentAccess.new(version.children) + - nameservers = children[:nameservers] || [] + - tech_contacts = children[:tech_contacts] || [] + - admin_contacts = children[:admin_contacts] || [] + - registrant = children[:registrant] || [] + - event = version.event + - creator = plain_username(version.terminator) + - elsif pending_user # pending history + - nameservers = domain.nameservers + - tech_contacts = domain.tech_contacts + - admin_contacts = domain.admin_contacts + - registrant = [domain.registrant] + - event = 'PENDING' + - creator = pending_user.try(:username) + - else # if legacy data not presentable + - nameservers = [] + - tech_contacts = [] + - admin_contacts = [] + - registrant = [] + - event = 'Log data is not viewable' + - creator = '' %td %p.nowrap = l(domain.updated_at, format: :short) - = version.event + = event %p.text-right - = version.terminator + = creator %td %p diff --git a/app/views/admin/domain_versions/index.haml b/app/views/admin/domain_versions/index.haml index 58bb175ab..ef31d2c17 100644 --- a/app/views/admin/domain_versions/index.haml +++ b/app/views/admin/domain_versions/index.haml @@ -17,6 +17,11 @@ %th{class: 'col-xs-2'}= t(:registrar) %tbody + - if @pending_domain.present? + %tr.small + = render 'admin/domain_versions/version', + domain: @pending_domain, pending_user: @pending_user + - if @domain.versions.present? %tr.small = render 'admin/domain_versions/version', diff --git a/app/views/admin/domains/partials/_statuses.haml b/app/views/admin/domains/partials/_statuses.haml index 51a88b18b..82480c7a6 100644 --- a/app/views/admin/domains/partials/_statuses.haml +++ b/app/views/admin/domains/partials/_statuses.haml @@ -8,7 +8,11 @@ %th{class: 'col-xs-6'}= t(:status) %th{class: 'col-xs-6'}= t(:description) %tbody - - @domain.statuses.each do |x| + - @domain.statuses.each do |status| %tr - %td= x + %td + - if [DomainStatus::PENDING_UPDATE, DomainStatus::PENDING_DELETE].include? status + = link_to status, admin_domain_domain_versions_path(@domain.id) + - else + = status %td From 17eec8e298cd6b19c2b5c858d4e694401cb605c2 Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Tue, 11 Aug 2015 00:04:36 +0300 Subject: [PATCH 6/7] Updated domain status view for pending #2785 --- app/controllers/admin/domains_controller.rb | 2 +- app/models/domain.rb | 8 ++++ app/views/admin/domains/edit.haml | 1 + .../domains/form_partials/_statuses.haml | 46 ++++++++++++------- .../admin/domains/partials/_statuses.haml | 4 +- 5 files changed, 41 insertions(+), 20 deletions(-) diff --git a/app/controllers/admin/domains_controller.rb b/app/controllers/admin/domains_controller.rb index c5d60ced3..ed0ac3c17 100644 --- a/app/controllers/admin/domains_controller.rb +++ b/app/controllers/admin/domains_controller.rb @@ -83,7 +83,7 @@ class Admin::DomainsController < AdminController def domain_params if params[:domain] - params.require(:domain).permit({ statuses: [] }) + params.require(:domain).permit({ statuses: [], status_notes_array: [] }) else { statuses: [] } end diff --git a/app/models/domain.rb b/app/models/domain.rb index dcdcbc120..3f06fe15b 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -681,5 +681,13 @@ class Domain < ActiveRecord::Base def update_whois_record whois_record.blank? ? create_whois_record : whois_record.save end + + def status_notes_array=(notes) + self.status_notes = {} + notes ||= [] + statuses.each_with_index do |status, i| + status_notes[status] = notes[i] + end + end end # rubocop: enable Metrics/ClassLength diff --git a/app/views/admin/domains/edit.haml b/app/views/admin/domains/edit.haml index 4b1c25ca6..36ddb3777 100644 --- a/app/views/admin/domains/edit.haml +++ b/app/views/admin/domains/edit.haml @@ -1,4 +1,5 @@ - content_for :actions do + = link_to(t(:add_new_status), '#', class: 'btn btn-primary js-add-status') = link_to(t(:back_to_domain), [:admin, @domain], class: 'btn btn-default') = render 'shared/title', name: "#{t(:edit)}: #{@domain.name}" diff --git a/app/views/admin/domains/form_partials/_statuses.haml b/app/views/admin/domains/form_partials/_statuses.haml index 52b9282ef..6b1c67b43 100644 --- a/app/views/admin/domains/form_partials/_statuses.haml +++ b/app/views/admin/domains/form_partials/_statuses.haml @@ -1,29 +1,41 @@ -#domain-statuses - - @server_statuses.each do |x| +#js-statuses + - f.object.statuses.each do |s| + - disabled = !DomainStatus::SERVER_STATUSES.include?(s) + - disabled_style = disabled ? 'display: none' : '' + - delete_style = [DomainStatus::OK].include?(s) ? 'display: none' : '' + .panel.panel-default .panel-heading.clearfix .pull-left= t(:status) .pull-right - = link_to(t(:add_another), '#', class: 'btn btn-primary btn-xs add-domain-status') - = link_to(t(:delete), '#', class: 'btn btn-danger btn-xs destroy-status') + = link_to(t(:delete), '#', class: 'btn btn-danger btn-xs js-destroy-status', style: delete_style) .panel-body .form-group = f.label 'status', class: 'col-md-2 control-label' .col-md-10 - = select_tag 'domain[statuses][]', options_for_select(DomainStatus.statuses_for_admin, x), include_blank: true, class: 'form-control' + .js-select{style: disabled_style} + = select_tag 'domain[statuses][]', + options_for_select(DomainStatus.statuses_for_admin, s), + include_blank: true, class: "form-control" + - if disabled + .disabled-value.js-disabled-value + = s + = hidden_field_tag 'domain[statuses][]', s, readonly: true .form-group - = label_tag t(:description), nil, class: 'col-md-2 control-label' + = label_tag t(:notes), nil, class: 'col-md-2 control-label' .col-md-10 - = text_field_tag :description, nil, class: 'form-control', autocomplete: 'off' - - @other_statuses.each do |x| - = hidden_field_tag 'domain[statuses][]', x, readonly: true -:coffee - $("#domain-statuses").nestedAttributes - bindAddTo: $(".add-domain-status") + - value = f.object.new_record? ? '' : f.object.status_notes[s] + = text_field_tag 'domain[status_notes_array][]', value, class: 'form-control' - $('.destroy-status').on 'click', (e) -> +:coffee + $("#js-statuses").nestedAttributes + bindAddTo: $(".js-add-status") + afterAdd: (el) -> + if el.find('.js-disabled-value') + el.find('.js-disabled-value').remove() + el.find('.js-select').show() + el.find('.js-destroy-status').show() + + $(document).on 'click', '.js-destroy-status', (e) -> e.preventDefault() - if $('.panel').length > 1 - $(this).parents('.panel').remove() - else - $(this).parents('.panel').find('select').val('') + $(this).parents('.panel').remove() diff --git a/app/views/admin/domains/partials/_statuses.haml b/app/views/admin/domains/partials/_statuses.haml index 82480c7a6..0f05f25d8 100644 --- a/app/views/admin/domains/partials/_statuses.haml +++ b/app/views/admin/domains/partials/_statuses.haml @@ -6,7 +6,7 @@ %thead %tr %th{class: 'col-xs-6'}= t(:status) - %th{class: 'col-xs-6'}= t(:description) + %th{class: 'col-xs-6'}= t(:notes) %tbody - @domain.statuses.each do |status| %tr @@ -15,4 +15,4 @@ = link_to status, admin_domain_domain_versions_path(@domain.id) - else = status - %td + %td= @domain.status_notes[status] From 7e340415e1cffce7e49987fc3f6e8bb6b4af96cd Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Tue, 11 Aug 2015 10:31:25 +0300 Subject: [PATCH 7/7] Rubocop updates --- app/controllers/admin/domain_versions_controller.rb | 2 ++ app/controllers/admin/pricelists_controller.rb | 1 - app/helpers/application_helper.rb | 2 +- app/models/domain.rb | 2 ++ spec/models/domain_spec.rb | 2 +- spec/models/zonefile_setting_spec.rb | 4 +++- 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/domain_versions_controller.rb b/app/controllers/admin/domain_versions_controller.rb index 9700e26c1..ffb6b50e2 100644 --- a/app/controllers/admin/domain_versions_controller.rb +++ b/app/controllers/admin/domain_versions_controller.rb @@ -1,6 +1,7 @@ class Admin::DomainVersionsController < AdminController load_and_authorize_resource + # rubocop:disable Style/GuardClause def index @domain = Domain.find(params[:domain_id]) @versions = @domain.versions @@ -11,6 +12,7 @@ class Admin::DomainVersionsController < AdminController @pending_domain = Epp::Domain.new_from_epp(frame, @pending_user) end end + # rubocop:enable Style/GuardClause # def index # # @q = DomainVersion.deleted.search(params[:q]) diff --git a/app/controllers/admin/pricelists_controller.rb b/app/controllers/admin/pricelists_controller.rb index ce1431ab0..4de35c2c9 100644 --- a/app/controllers/admin/pricelists_controller.rb +++ b/app/controllers/admin/pricelists_controller.rb @@ -51,5 +51,4 @@ class Admin::PricelistsController < AdminController params.require(:pricelist).permit(:operation_category, :category, :price_category, :duration, :price, :valid_from, :valid_to) end - end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6ab5fe4e8..7a75ff78f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -48,7 +48,7 @@ module ApplicationHelper def currency(amount) amount ||= 0 - ("%01.2f" % amount.round(2)).sub(/\./, ',') + format("%01.2f", amount.round(2)).sub(/\./, ',') end def plain_username(username) diff --git a/app/models/domain.rb b/app/models/domain.rb index 3f06fe15b..af1a7240a 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -546,6 +546,7 @@ class Domain < ActiveRecord::Base self.delete_at = outzone_at + Setting.redemption_grace_period.days end + # rubocop:disable Metrics/AbcSize def set_force_delete self.statuses_backup = statuses statuses.delete(DomainStatus::CLIENT_DELETE_PROHIBITED) @@ -572,6 +573,7 @@ class Domain < ActiveRecord::Base self.force_delete_at = Time.zone.now + Setting.redemption_grace_period.days unless force_delete_at save(validate: false) end + # rubocop:enable Metrics/AbcSize def unset_force_delete s = [] diff --git a/spec/models/domain_spec.rb b/spec/models/domain_spec.rb index 1b9f7568f..a5a48ddb6 100644 --- a/spec/models/domain_spec.rb +++ b/spec/models/domain_spec.rb @@ -239,7 +239,7 @@ describe Domain do DomainStatus::CLIENT_HOLD, DomainStatus::EXPIRED, DomainStatus::SERVER_HOLD, - DomainStatus::DELETE_CANDIDATE, + DomainStatus::DELETE_CANDIDATE ] @domain.save diff --git a/spec/models/zonefile_setting_spec.rb b/spec/models/zonefile_setting_spec.rb index 9386c3b1d..9405aa063 100644 --- a/spec/models/zonefile_setting_spec.rb +++ b/spec/models/zonefile_setting_spec.rb @@ -41,7 +41,9 @@ describe ZonefileSetting do it 'should not place serverHold nor clientHold domains into zonefile' do Fabricate(:zonefile_setting) - d = Fabricate(:domain_with_dnskeys, name: 'testzone.ee', statuses: ['serverHold', 'serverDeleteProhibited', 'clientHold']) + d = Fabricate(:domain_with_dnskeys, + name: 'testzone.ee', + statuses: ['serverHold', 'serverDeleteProhibited', 'clientHold']) d.nameservers << Nameserver.new({ hostname: "ns.#{d.name}", ipv4: '123.123.123.123',