subj_models 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/subj_models/brand.rb +4 -0
- data/lib/subj_models/content_block.rb +3 -1
- data/lib/subj_models/nomenclature.rb +9 -3
- data/lib/subj_models/services/types_support.rb +2 -1
- data/lib/subj_models/user.rb +2 -4
- data/lib/subj_models/version.rb +1 -1
- data/lib/subj_models/video.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84241f6129048ebc4734a5b85a99d1ca8dbf02d0
|
4
|
+
data.tar.gz: f626cdcd3b1d2b5b06f617733b6c4ff97c884d5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e182bdd11fee25f45f63acb62500d154679df971a5de1d7da2ef6c317e21c09fb910a584babaaf6c434aef149b972830e39ee8c93ea9f7c25e46f72942b71e6
|
7
|
+
data.tar.gz: 6455c3d590b45ee561f73114569c59fd620b24491b2e2555ef76b8498c53dcb9d60a1fd40461df7898f15c73b0930a741a0ec6be25501f49ff3f0c3524e9b4c6
|
data/lib/subj_models/brand.rb
CHANGED
@@ -15,6 +15,7 @@ module SubjModels
|
|
15
15
|
has_many :brand_lines, dependent: :destroy
|
16
16
|
has_many :nomenclatures
|
17
17
|
has_many :videos
|
18
|
+
has_and_belongs_to_many :users
|
18
19
|
|
19
20
|
belongs_to :content_block1, class_name: "ContentBlock"
|
20
21
|
belongs_to :content_block2, class_name: "ContentBlock"
|
@@ -25,6 +26,9 @@ module SubjModels
|
|
25
26
|
|
26
27
|
validates :name, presence: true
|
27
28
|
|
29
|
+
scope :in_index_list, -> condition { where(show_on_index: condition) }
|
30
|
+
scope :in_recommended_list, -> condition { where(is_recommended: condition) }
|
31
|
+
|
28
32
|
scope :category_id, -> (category_id) do
|
29
33
|
return all if category_id.blank?
|
30
34
|
joins(brand_lines: [{ nomenclatures: :category}]).where('categories.id' => category_id)
|
@@ -22,7 +22,7 @@ module SubjModels
|
|
22
22
|
has_many :nomenclature_files, dependent: :destroy
|
23
23
|
has_many :events
|
24
24
|
has_many :attribute_values, dependent: :destroy
|
25
|
-
has_many :nomenclature_prices
|
25
|
+
has_many :nomenclature_prices, dependent: :destroy
|
26
26
|
|
27
27
|
belongs_to :analog_related_nomenclature, class_name: "Nomenclature"
|
28
28
|
has_many :analogs, foreign_key: "analog_related_nomenclature_id", class_name: "Nomenclature"
|
@@ -38,6 +38,7 @@ module SubjModels
|
|
38
38
|
scope :brand_line_ids, -> (brand_line_id) { where(brand_line_id: brand_line_id) }
|
39
39
|
scope :with_action, -> { joins(:actions).distinct }
|
40
40
|
scope :is_recommended, -> condition { where(is_recommended: condition) }
|
41
|
+
scope :in_index_list, -> condition { where(show_on_index: condition) }
|
41
42
|
scope :is_stock, -> (condition) do
|
42
43
|
nomenclature_prices_join.joins("LEFT OUTER JOIN qualities ON qualities.id = nomenclature_prices.quality_id").where("qualities.is_stock" => condition)
|
43
44
|
end
|
@@ -124,7 +125,12 @@ module SubjModels
|
|
124
125
|
|
125
126
|
scope :brand_ids, -> (brand) do
|
126
127
|
return all unless brand.present?
|
127
|
-
|
128
|
+
where(brand: brand)
|
129
|
+
end
|
130
|
+
|
131
|
+
scope :with_brand, -> (brand) do
|
132
|
+
return none unless brand.present?
|
133
|
+
where(brand: brand)
|
128
134
|
end
|
129
135
|
|
130
136
|
scope :brand_line_ids, -> (ids) do
|
@@ -143,7 +149,7 @@ module SubjModels
|
|
143
149
|
end
|
144
150
|
|
145
151
|
def to_s
|
146
|
-
|
152
|
+
name.to_s # TODO
|
147
153
|
end
|
148
154
|
|
149
155
|
def self.name_field_update(field)
|
@@ -8,8 +8,9 @@ module SubjModels
|
|
8
8
|
ADMIN = 1
|
9
9
|
LEGAL_PERSON = 2
|
10
10
|
NATURAL_PERSON = 3
|
11
|
+
DISTRIBUTOR = 4
|
11
12
|
|
12
|
-
USER_TYPES = { 'админ' => ADMIN, 'юридическое лицо' => LEGAL_PERSON, 'физическое лицо' => NATURAL_PERSON }
|
13
|
+
USER_TYPES = { 'админ' => ADMIN, 'юридическое лицо' => LEGAL_PERSON, 'физическое лицо' => NATURAL_PERSON, 'поставщик' => DISTRIBUTOR }
|
13
14
|
end
|
14
15
|
|
15
16
|
module EventTypes
|
data/lib/subj_models/user.rb
CHANGED
@@ -29,6 +29,7 @@ module SubjModels
|
|
29
29
|
enum user_type: USER_TYPES
|
30
30
|
enum card_receive_type: CARD_RECEIVE_TYPES
|
31
31
|
|
32
|
+
|
32
33
|
has_many :orders
|
33
34
|
has_many :user_specialization_approvals, dependent: :destroy
|
34
35
|
has_many :user_cards, dependent: :destroy
|
@@ -36,6 +37,7 @@ module SubjModels
|
|
36
37
|
has_many :user_delivery_addresses, dependent: :destroy
|
37
38
|
|
38
39
|
has_and_belongs_to_many :user_specializations
|
40
|
+
has_and_belongs_to_many :brands
|
39
41
|
|
40
42
|
belongs_to :document_file
|
41
43
|
belongs_to :city
|
@@ -96,10 +98,6 @@ module SubjModels
|
|
96
98
|
email
|
97
99
|
end
|
98
100
|
|
99
|
-
def admin?
|
100
|
-
self.user_type == 'админ'
|
101
|
-
end
|
102
|
-
|
103
101
|
def available_nomenclature_ids
|
104
102
|
Nomenclature.joins(access_groups: [user_specializations: :users]).where("users.id" => self.id).uniq.pluck(:id)
|
105
103
|
end
|
data/lib/subj_models/version.rb
CHANGED
data/lib/subj_models/video.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: subj_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denys Dvoriashyn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
version: '0'
|
129
129
|
requirements: []
|
130
130
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.
|
131
|
+
rubygems_version: 2.5.1
|
132
132
|
signing_key:
|
133
133
|
specification_version: 4
|
134
134
|
summary: Move models from some project to gem.
|