diff --git a/app/controllers/admin/disputes_controller.rb b/app/controllers/admin/disputes_controller.rb index 8a8997f63..62e0c69b6 100644 --- a/app/controllers/admin/disputes_controller.rb +++ b/app/controllers/admin/disputes_controller.rb @@ -38,7 +38,7 @@ module Admin # PATCH/PUT /admin/disputes/1 def update - if @dispute.update(dispute_params.except(:domain_name)) + if @dispute.update(dispute_params.except(:domain_name, :starts_at)) redirect_to admin_disputes_url, notice: 'Dispute was successfully updated.' else render :edit @@ -68,7 +68,9 @@ module Admin # Only allow a trusted parameter "white list" through. def dispute_params - params.require(:dispute).permit(:domain_name, :password, :starts_at, :comment) + params.require(:dispute) + .permit(:domain_name, :password, :starts_at, :comment) + .with_defaults(starts_at: Time.zone.today) end end end diff --git a/app/interactions/actions/domain_update.rb b/app/interactions/actions/domain_update.rb index 7da22e539..5165a68c8 100644 --- a/app/interactions/actions/domain_update.rb +++ b/app/interactions/actions/domain_update.rb @@ -209,9 +209,9 @@ module Actions end def verify_registrant_change? - return if !@changes_registrant || params[:registrant][:verified] == true - return true unless domain.disputed? return validate_dispute_case if params[:reserved_pw] + return false if !@changes_registrant || params[:registrant][:verified] == true + return true unless domain.disputed? domain.add_epp_error('2304', nil, nil, 'Required parameter missing; reservedpw element ' \ 'required for dispute domains') diff --git a/app/models/dispute.rb b/app/models/dispute.rb index 6690e0e3c..f5a948355 100644 --- a/app/models/dispute.rb +++ b/app/models/dispute.rb @@ -43,10 +43,10 @@ class Dispute < ApplicationRecord end def generate_data - return if starts_at > Time.zone.today || expires_at < Time.zone.today + return false if starts_at > Time.zone.today || expires_at < Time.zone.today domain&.mark_as_disputed - return if domain + return true if domain wr = Whois::Record.find_or_initialize_by(name: domain_name) wr.json = @json = generate_json(wr, domain_status: 'disputed') diff --git a/app/models/domain.rb b/app/models/domain.rb index 56dd91919..4a246d76f 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -33,6 +33,8 @@ class Domain < ApplicationRecord has_many :tech_domain_contacts accepts_nested_attributes_for :tech_domain_contacts, allow_destroy: true, reject_if: :tech_change_prohibited? + ID_CHAR_LIMIT = 8 + def registrant_change_prohibited? statuses.include? DomainStatus::SERVER_REGISTRANT_CHANGE_PROHIBITED end @@ -331,7 +333,12 @@ class Domain < ApplicationRecord end def roid - "EIS-#{id}" + id_size = id.to_s.size + if id_size <= ID_CHAR_LIMIT + "EIS-#{id}" + else + roid_with_prefix(id_size) + end end def puny_label @@ -734,4 +741,13 @@ class Domain < ApplicationRecord def self.uses_zone?(zone) exists?(["name ILIKE ?", "%.#{zone.origin}"]) end + + private + + def roid_with_prefix(id_size) + id_delta = id_size - ID_CHAR_LIMIT + id_prefix = id.to_s.split(//).first(id_delta).join('').to_s + id_postfix = id.to_s.split(//).last(id_size - id_delta).join('').to_s + "EIS#{id_prefix}-#{id_postfix}" + end end diff --git a/app/views/admin/disputes/_form.html.erb b/app/views/admin/disputes/_form.html.erb index 2a3fb722f..c6fbbee1b 100644 --- a/app/views/admin/disputes/_form.html.erb +++ b/app/views/admin/disputes/_form.html.erb @@ -11,7 +11,7 @@
As per domain law, expiry time is <%= Setting.dispute_period_in_months / 12 %> years ahead from start date.
+As per domain law, expiry time is <%= Setting.dispute_period_in_months / 12 %> years ahead from creation date (today).