subj_models 0.1.04 → 0.1.05
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/subj_models/user.rb +48 -41
- data/lib/subj_models/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82d89cdbd2b65439c84b982cb18691fbce5695c5
|
4
|
+
data.tar.gz: c472c01f696b0ca810e2a050bb98dfd17337a510
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f07d137c04074a9eea278c5c204f4833f66e53fc2f490de16c47d96199affa66faaf02f6afdf53ac65f9caf7edaf49b5ed75bb3b26c500b4da176dbf03a19a19
|
7
|
+
data.tar.gz: f2edcda45a78ba37c40fd6b94265086c1af2ca0fd60352571ffb78b37927453aa298dfd06fabadf307b9ed82055c56a2863082c5795519b4c6ce52f4f0957baa
|
data/lib/subj_models/user.rb
CHANGED
@@ -2,47 +2,54 @@ module SubjModels
|
|
2
2
|
|
3
3
|
module User
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
5
|
+
def self.included(including_class)
|
6
|
+
|
7
|
+
including_class.class_eval do
|
8
|
+
|
9
|
+
include ComprisingExternalId
|
10
|
+
include TypesSupport::UserTypes
|
11
|
+
include TypesSupport::CardReceiveTypes
|
12
|
+
include RademadeAdmin::UserModule
|
13
|
+
include SharedScopes
|
14
|
+
include ValuesChecker
|
15
|
+
|
16
|
+
enum user_type: USER_TYPES
|
17
|
+
enum card_receive_type: CARD_RECEIVE_TYPES
|
18
|
+
|
19
|
+
has_many :orders
|
20
|
+
has_many :user_specialization_approvals, dependent: :destroy
|
21
|
+
has_many :user_cards, dependent: :destroy
|
22
|
+
has_one :user_work_place, dependent: :destroy
|
23
|
+
has_many :user_delivery_addresses, dependent: :destroy
|
24
|
+
|
25
|
+
has_and_belongs_to_many :user_specializations
|
26
|
+
|
27
|
+
belongs_to :document_file
|
28
|
+
belongs_to :city
|
29
|
+
belongs_to :avatar, class_name: "DocumentFile"
|
30
|
+
|
31
|
+
validates :first_name, :last_name, presence: true,
|
32
|
+
on: :update,
|
33
|
+
unless: lambda { |user| user.legal_person? || user.skip_validations }
|
34
|
+
validates :email, uniqueness: { case_sensitive: false }, presence: true,
|
35
|
+
on: :update,
|
36
|
+
unless: :skip_validations
|
37
|
+
validates :phone, uniqueness: { case_sensitive: false }, presence: true,
|
38
|
+
on: :update,
|
39
|
+
unless: :skip_validations
|
40
|
+
validates :user_type, inclusion: { in: user_types.keys },
|
41
|
+
on: :update,
|
42
|
+
unless: :skip_validations
|
43
|
+
|
44
|
+
attr_accessor :skip_validations
|
45
|
+
|
46
|
+
scope :external_id, -> external_id do
|
47
|
+
external_id ? where(external_id: external_id) : User.none
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
46
53
|
|
47
54
|
def natural_person?
|
48
55
|
user_type == USER_TYPES.key(NATURAL_PERSON)
|
data/lib/subj_models/version.rb
CHANGED