From 928f96691cc8d8e270af06c2f1fd8628f55286f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Erik=20=C3=95unapuu?= Date: Mon, 4 May 2020 08:14:56 +0300 Subject: [PATCH] Make dispute domain_name read only --- app/models/dispute.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/dispute.rb b/app/models/dispute.rb index 19644c5f8..a83157ecd 100644 --- a/app/models/dispute.rb +++ b/app/models/dispute.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - class Dispute < ApplicationRecord validates :domain_name, :password, :starts_at, :expires_at, presence: true before_validation :fill_empty_passwords @@ -10,6 +8,7 @@ class Dispute < ApplicationRecord with_options on: :admin do validate :validate_start_date end + before_save :set_expiry_date before_save :sync_reserved_password before_save :generate_data @@ -19,6 +18,8 @@ class Dispute < ApplicationRecord scope :active, -> { where('expires_at >= ? AND closed = false', Time.zone.today) } scope :closed, -> { where(closed: true) } + attr_readonly :domain_name + alias_attribute :name, :domain_name def self.close_by_domain(domain_name) @@ -97,6 +98,7 @@ class Dispute < ApplicationRecord private def validate_start_date + puts 'EXECUTED' return if starts_at.nil? errors.add(:starts_at, :past) if starts_at.past?