mirror of
https://github.com/internetee/registry.git
synced 2025-07-02 01:03:35 +02:00
Remove Registrar from User
This commit is contained in:
parent
9c8fed999d
commit
2c35aa1471
14 changed files with 12 additions and 72 deletions
|
@ -7,29 +7,19 @@ class User < ActiveRecord::Base
|
|||
# TODO: Estonian id validation
|
||||
|
||||
belongs_to :role
|
||||
belongs_to :registrar
|
||||
belongs_to :country
|
||||
|
||||
validates :username, :password, presence: true
|
||||
validates :identity_code, uniqueness: true, allow_blank: true
|
||||
validates :identity_code, presence: true, if: -> { country.iso == 'EE' }
|
||||
validates :email, presence: true, if: -> { country.iso != 'EE' }
|
||||
validates :registrar, presence: true, if: -> { !admin }
|
||||
|
||||
validate :validate_identity_code
|
||||
|
||||
before_save -> { self.registrar = nil if admin? }
|
||||
|
||||
attr_accessor :registrar_typeahead
|
||||
|
||||
def to_s
|
||||
username
|
||||
end
|
||||
|
||||
def registrar_typeahead
|
||||
@registrar_typeahead || registrar || nil
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def validate_identity_code
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue