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

This commit is contained in:
Martin Lensment 2015-08-11 10:35:49 +03:00
commit beaf8fc7b6
27 changed files with 257 additions and 87 deletions

View file

@ -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]

View file

@ -1,10 +1,18 @@
class Admin::DomainVersionsController < AdminController
load_and_authorize_resource
# rubocop:disable Style/GuardClause
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
# rubocop:enable Style/GuardClause
# def index
# # @q = DomainVersion.deleted.search(params[:q])

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -45,4 +45,14 @@ module ApplicationHelper
# can be api user or some other user
link_to(model.updator, ['admin', model.updator])
end
def currency(amount)
amount ||= 0
format("%01.2f", amount.round(2)).sub(/\./, ',')
end
def plain_username(username)
username ||= ''
username.split(':').last.to_s.strip
end
end

View file

@ -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

View file

@ -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 = []
@ -681,5 +683,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

View file

@ -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)

View file

@ -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'

View file

@ -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

View file

@ -1,16 +1,37 @@
- if version.present? && domain.present?
- 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

View file

@ -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',

View file

@ -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}"

View file

@ -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('')

View file

@ -6,9 +6,13 @@
%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 |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= @domain.status_notes[status]

View file

@ -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)

View file

@ -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')

View file

@ -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)
@ -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

View file

@ -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)

View file

@ -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

View file

@ -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'

View file

@ -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

View file

@ -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))

View file

@ -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

View file

@ -239,7 +239,7 @@ describe Domain do
DomainStatus::CLIENT_HOLD,
DomainStatus::EXPIRED,
DomainStatus::SERVER_HOLD,
DomainStatus::DELETE_CANDIDATE,
DomainStatus::DELETE_CANDIDATE
]
@domain.save

View file

@ -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',