mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 17:01:44 +02:00
User form
This commit is contained in:
parent
14f9304c6d
commit
0e7e83134c
11 changed files with 252 additions and 6 deletions
|
@ -51,7 +51,6 @@ class Domain < ActiveRecord::Base
|
|||
validate :validate_domain_statuses_uniqueness, if: :new_record?
|
||||
|
||||
attr_accessor :owner_contact_typeahead
|
||||
attr_accessor :registrar_typeahead
|
||||
|
||||
def name=(value)
|
||||
value.strip!
|
||||
|
@ -64,10 +63,6 @@ class Domain < ActiveRecord::Base
|
|||
@owner_contact_typeahead || owner_contact.try(:name) || nil
|
||||
end
|
||||
|
||||
def registrar_typeahead
|
||||
@registrar_typeahead || registrar || nil
|
||||
end
|
||||
|
||||
def pending_transfer
|
||||
domain_transfers.find_by(status: DomainTransfer::PENDING)
|
||||
end
|
||||
|
|
|
@ -8,4 +8,32 @@ class User < ActiveRecord::Base
|
|||
|
||||
belongs_to :role
|
||||
belongs_to :registrar
|
||||
|
||||
validates :username, :password, presence: true
|
||||
validates :identity_code, uniqueness: true, allow_blank: true
|
||||
validate :registrar_presence
|
||||
|
||||
before_save :manage_registrar
|
||||
|
||||
attr_accessor :registrar_typeahead
|
||||
|
||||
def to_s
|
||||
username
|
||||
end
|
||||
|
||||
def registrar_typeahead
|
||||
@registrar_typeahead || registrar || nil
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def registrar_presence
|
||||
if !admin && !registrar
|
||||
errors.add(:registrar, :blank)
|
||||
end
|
||||
end
|
||||
|
||||
def manage_registrar
|
||||
self.registrar = nil if admin?
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue