mirror of
https://github.com/internetee/registry.git
synced 2025-05-28 07:02:04 +02:00
parent
39d7c6ad1d
commit
ad0220088a
30 changed files with 697 additions and 59 deletions
31
app/models/concerns/domain/expirable.rb
Normal file
31
app/models/concerns/domain/expirable.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
module Concerns::Domain::Expirable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
alias_attribute :expire_time, :valid_to
|
||||
end
|
||||
|
||||
class_methods do
|
||||
def expired
|
||||
where("#{attribute_alias(:expire_time)} <= ?", Time.zone.now)
|
||||
end
|
||||
end
|
||||
|
||||
def registered?
|
||||
valid_to >= Time.zone.now
|
||||
end
|
||||
|
||||
def expired?
|
||||
statuses.include?(DomainStatus::EXPIRED)
|
||||
end
|
||||
|
||||
def expirable?
|
||||
return false if valid_to > Time.zone.now
|
||||
|
||||
if expired? && outzone_at.present? && delete_at.present?
|
||||
return false
|
||||
end
|
||||
|
||||
true
|
||||
end
|
||||
end
|
|
@ -250,6 +250,13 @@ class Contact < ActiveRecord::Base
|
|||
kit.to_pdf
|
||||
end
|
||||
|
||||
def names
|
||||
pluck(:name)
|
||||
end
|
||||
|
||||
def emails
|
||||
pluck(:email)
|
||||
end
|
||||
end
|
||||
|
||||
def roid
|
||||
|
|
|
@ -3,12 +3,16 @@ class Domain < ActiveRecord::Base
|
|||
include UserEvents
|
||||
include Versions # version/domain_version.rb
|
||||
include Statuses
|
||||
include Concerns::Domain::Expirable
|
||||
has_paper_trail class_name: "DomainVersion", meta: { children: :children_log }
|
||||
|
||||
attr_accessor :roles
|
||||
|
||||
attr_accessor :legal_document_id
|
||||
|
||||
alias_attribute :on_hold_time, :outzone_at
|
||||
alias_attribute :delete_time, :delete_at
|
||||
|
||||
# TODO: whois requests ip whitelist for full info for own domains and partial info for other domains
|
||||
# TODO: most inputs should be trimmed before validatation, probably some global logic?
|
||||
|
||||
|
@ -746,6 +750,21 @@ class Domain < ActiveRecord::Base
|
|||
DomainMailer.send(action, DomainMailModel.new(self).send(action)).deliver
|
||||
end
|
||||
|
||||
def admin_contact_names
|
||||
admin_contacts.names
|
||||
end
|
||||
|
||||
def admin_contact_emails
|
||||
admin_contacts.emails
|
||||
end
|
||||
|
||||
def tech_contact_names
|
||||
tech_contacts.names
|
||||
end
|
||||
|
||||
def nameserver_hostnames
|
||||
nameservers.hostnames
|
||||
end
|
||||
|
||||
def self.to_csv
|
||||
CSV.generate do |csv|
|
||||
|
|
|
@ -18,7 +18,7 @@ class Nameserver < ActiveRecord::Base
|
|||
before_validation :normalize_attributes
|
||||
before_validation :check_puny_symbols
|
||||
before_validation :check_label_length
|
||||
|
||||
|
||||
delegate :name, to: :domain, prefix: true
|
||||
|
||||
def epp_code_map
|
||||
|
@ -117,5 +117,9 @@ class Nameserver < ActiveRecord::Base
|
|||
# ignoring ips
|
||||
rel
|
||||
end
|
||||
|
||||
def hostnames
|
||||
pluck(:hostname)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue