subj_sub_models 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.idea/modules.xml +1 -1
- data/.idea/workspace.xml +5 -5
- data/Gemfile +1 -1
- data/README.md +3 -3
- data/bin/console +1 -1
- data/lib/subj_models/access_group.rb +22 -0
- data/lib/subj_models/action_banner.rb +37 -0
- data/lib/subj_models/attribute_value.rb +32 -0
- data/lib/subj_models/brand.rb +74 -0
- data/lib/subj_models/brand_line.rb +51 -0
- data/lib/subj_models/category.rb +36 -0
- data/lib/subj_models/city.rb +31 -0
- data/lib/subj_models/concerns/comprising_external_id.rb +37 -0
- data/lib/subj_models/concerns/shared_scopes.rb +15 -0
- data/lib/subj_models/content_block.rb +28 -0
- data/lib/subj_models/document_file.rb +38 -0
- data/lib/subj_models/event.rb +79 -0
- data/lib/subj_models/event_booking.rb +39 -0
- data/lib/subj_models/event_schedule.rb +37 -0
- data/lib/subj_models/event_type.rb +27 -0
- data/lib/subj_models/faq.rb +46 -0
- data/lib/subj_models/global_notification.rb +16 -0
- data/lib/subj_models/manager.rb +31 -0
- data/lib/subj_models/measure_unit.rb +28 -0
- data/lib/subj_models/nomenclature.rb +166 -0
- data/lib/subj_models/nomenclature_access_group.rb +19 -0
- data/lib/subj_models/nomenclature_attribute.rb +27 -0
- data/lib/subj_models/nomenclature_file.rb +44 -0
- data/lib/subj_models/nomenclature_photo.rb +36 -0
- data/lib/subj_models/nomenclature_price.rb +39 -0
- data/lib/subj_models/nomenclature_review.rb +38 -0
- data/lib/subj_models/nomenclature_variety.rb +29 -0
- data/lib/subj_models/office.rb +40 -0
- data/lib/subj_models/office_contact.rb +41 -0
- data/lib/subj_models/order.rb +91 -0
- data/lib/subj_models/order_delivery_courier.rb +31 -0
- data/lib/subj_models/order_delivery_nova_poshta_warhouse.rb +20 -0
- data/lib/subj_models/order_delivery_pickup.rb +28 -0
- data/lib/subj_models/order_delivery_privatbank.rb +29 -0
- data/lib/subj_models/order_delivery_subj_courier.rb +25 -0
- data/lib/subj_models/order_item.rb +60 -0
- data/lib/subj_models/quality.rb +25 -0
- data/lib/subj_models/services/types_support.rb +122 -0
- data/lib/subj_models/services/values_checker.rb +11 -0
- data/lib/subj_models/specialist_activity.rb +33 -0
- data/lib/subj_models/specialist_activity_document_type.rb +29 -0
- data/lib/subj_models/template.rb +18 -0
- data/lib/subj_models/user.rb +131 -0
- data/lib/subj_models/user_card.rb +29 -0
- data/lib/subj_models/user_card_delivery.rb +29 -0
- data/lib/subj_models/user_delivery_address.rb +34 -0
- data/lib/subj_models/user_specialization.rb +38 -0
- data/lib/subj_models/user_specialization_approval.rb +33 -0
- data/lib/subj_models/user_work_place.rb +29 -0
- data/lib/subj_models/version.rb +3 -0
- data/lib/subj_models/video.rb +29 -0
- data/lib/subj_models.rb +49 -0
- data/subj_models.gemspec +33 -0
- data/subj_models.iml +9 -0
- metadata +56 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ea8cddfadab4bbb7e5b2b7d2503453fd6d9254d
|
4
|
+
data.tar.gz: 89e29d038a91a18f4b821119e56dc952eae71db6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b1f10492b0889c42293200ed6f2e836308c370c0e07ce86206d5c2026619d5b2ef435ee92defc8637f1cb432401d261f57c263119db941525286d2eaa739929
|
7
|
+
data.tar.gz: 26192b43ac16f52292ff2e53deb16234014086ace79361a29784666f877bba0260f5088cc5e49f94b3a5f1c8d08bcaa3a9a4245d659f88423ee48d1e7615f8a3
|
data/.gitignore
CHANGED
data/.idea/modules.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
<project version="4">
|
3
3
|
<component name="ProjectModuleManager">
|
4
4
|
<modules>
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/subj_models.iml" filepath="$PROJECT_DIR$/subj_models.iml" />
|
6
6
|
</modules>
|
7
7
|
</component>
|
8
8
|
</project>
|
data/.idea/workspace.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
<project version="4">
|
3
3
|
<component name="ChangeListManager">
|
4
4
|
<list default="true" id="df7164a7-6c43-42fd-8a2b-5000b47cabac" name="Default" comment="" />
|
5
|
-
<ignored path="
|
5
|
+
<ignored path="subj_models.iws" />
|
6
6
|
<ignored path=".idea/workspace.xml" />
|
7
7
|
<ignored path="$PROJECT_DIR$/out/" />
|
8
8
|
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
@@ -17,7 +17,7 @@
|
|
17
17
|
</component>
|
18
18
|
<component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
|
19
19
|
<component name="FavoritesManager">
|
20
|
-
<favorites_list name="
|
20
|
+
<favorites_list name="subj_models" />
|
21
21
|
</component>
|
22
22
|
<component name="GradleLocalSettings">
|
23
23
|
<option name="externalProjectsViewState">
|
@@ -65,17 +65,17 @@
|
|
65
65
|
<subPane>
|
66
66
|
<PATH>
|
67
67
|
<PATH_ELEMENT>
|
68
|
-
<option name="myItemId" value="
|
68
|
+
<option name="myItemId" value="subj_models" />
|
69
69
|
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
|
70
70
|
</PATH_ELEMENT>
|
71
71
|
</PATH>
|
72
72
|
<PATH>
|
73
73
|
<PATH_ELEMENT>
|
74
|
-
<option name="myItemId" value="
|
74
|
+
<option name="myItemId" value="subj_models" />
|
75
75
|
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
|
76
76
|
</PATH_ELEMENT>
|
77
77
|
<PATH_ELEMENT>
|
78
|
-
<option name="myItemId" value="
|
78
|
+
<option name="myItemId" value="subj_models" />
|
79
79
|
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
80
80
|
</PATH_ELEMENT>
|
81
81
|
</PATH>
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# SubjModels
|
2
2
|
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/subj_models`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
4
|
|
5
5
|
TODO: Delete this and the text above, and describe your gem
|
6
6
|
|
@@ -32,5 +32,5 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
32
|
|
33
33
|
## Contributing
|
34
34
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/subj_models.
|
36
36
|
|
data/bin/console
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'subj_models/concerns/comprising_external_id'
|
2
|
+
|
3
|
+
module SubjModels
|
4
|
+
|
5
|
+
module AccessGroupModule
|
6
|
+
|
7
|
+
def self.included(including_class)
|
8
|
+
|
9
|
+
including_class.class_eval do
|
10
|
+
|
11
|
+
include SubjModels::ComprisingExternalId
|
12
|
+
|
13
|
+
has_and_belongs_to_many :user_specializations
|
14
|
+
has_and_belongs_to_many :nomenclatures, through: :nomenclature_access_groups
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'subj_models/concerns/comprising_external_id'
|
2
|
+
|
3
|
+
module SubjModels
|
4
|
+
|
5
|
+
module ActionBannerModule
|
6
|
+
|
7
|
+
def self.included(including_class)
|
8
|
+
|
9
|
+
including_class.class_eval do
|
10
|
+
|
11
|
+
include SubjModels::ComprisingExternalId
|
12
|
+
|
13
|
+
has_and_belongs_to_many :cities
|
14
|
+
has_and_belongs_to_many :nomenclatures
|
15
|
+
has_and_belongs_to_many :brands
|
16
|
+
belongs_to :image, class_name: "DocumentFile"
|
17
|
+
belongs_to :categories_list_image, class_name: "DocumentFile"
|
18
|
+
|
19
|
+
validates :nomenclatures, presence: true
|
20
|
+
validates :name, presence: true
|
21
|
+
# validates :discount_percent,
|
22
|
+
# presence: true,
|
23
|
+
# numericality: {only_integer: true, greater_than_or_equal_to: 0, less_than_or_equal_to: 100}
|
24
|
+
|
25
|
+
scope :to_show, -> condition { where(to_show: condition) }
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_s
|
32
|
+
name
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'subj_models/concerns/comprising_external_id'
|
2
|
+
|
3
|
+
module SubjModels
|
4
|
+
|
5
|
+
module AttributeValueModule
|
6
|
+
|
7
|
+
def self.included(including_class)
|
8
|
+
|
9
|
+
including_class.class_eval do
|
10
|
+
|
11
|
+
include SubjModels::ComprisingExternalId
|
12
|
+
|
13
|
+
has_and_belongs_to_many :nomenclature_varieties
|
14
|
+
|
15
|
+
belongs_to :nomenclature
|
16
|
+
belongs_to :nomenclature_attribute
|
17
|
+
|
18
|
+
validates :nomenclature_value, :nomenclature_attribute, presence: true
|
19
|
+
|
20
|
+
scope :nomenclature_id, -> (nomenclature_id) { parent_id_scope("nomenclature", nomenclature_id) }
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_s
|
27
|
+
nomenclature_value
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'subj_models/concerns/comprising_external_id'
|
2
|
+
require 'subj_models/concerns/shared_scopes'
|
3
|
+
|
4
|
+
module SubjModels
|
5
|
+
|
6
|
+
module BrandModule
|
7
|
+
|
8
|
+
def self.included(including_class)
|
9
|
+
|
10
|
+
including_class.class_eval do
|
11
|
+
|
12
|
+
include SubjModels::SharedScopes
|
13
|
+
include SubjModels::ComprisingExternalId
|
14
|
+
|
15
|
+
has_many :brand_lines, dependent: :destroy
|
16
|
+
has_many :nomenclatures
|
17
|
+
has_many :videos
|
18
|
+
has_many :events
|
19
|
+
|
20
|
+
has_and_belongs_to_many :users
|
21
|
+
has_and_belongs_to_many :action_banners
|
22
|
+
|
23
|
+
belongs_to :content_block1, class_name: "ContentBlock"
|
24
|
+
belongs_to :content_block2, class_name: "ContentBlock"
|
25
|
+
belongs_to :content_block3, class_name: "ContentBlock"
|
26
|
+
belongs_to :document_file
|
27
|
+
|
28
|
+
before_validation :set_first_letter, if: :name_changed?
|
29
|
+
|
30
|
+
validates :name, presence: true
|
31
|
+
|
32
|
+
scope :in_index_list, -> condition { where(show_on_index: condition) }
|
33
|
+
scope :in_recommended_list, -> condition { where(is_recommended: condition) }
|
34
|
+
|
35
|
+
scope :category_id, -> (category_id) do
|
36
|
+
return all if category_id.blank?
|
37
|
+
joins(brand_lines: [{ nomenclatures: :category}]).where('categories.id' => category_id)
|
38
|
+
end
|
39
|
+
|
40
|
+
scope :by_first_letters, -> (by_first_letters) do
|
41
|
+
unless by_first_letters.blank?
|
42
|
+
where(first_letter: by_first_letters)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
scope :has_events, -> do
|
47
|
+
joins(events: :event_schedule).where('event_schedules.event_date >= ?', DateTime.now.beginning_of_day).uniq
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_s
|
55
|
+
name
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def self.searchable_fields
|
61
|
+
[:name, :hidden_name]
|
62
|
+
end
|
63
|
+
|
64
|
+
def order_params
|
65
|
+
[ :order_by_name, :order_by_popularity ]
|
66
|
+
end
|
67
|
+
|
68
|
+
def set_first_letter
|
69
|
+
self.first_letter = name[0].downcase
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'subj_models/concerns/comprising_external_id'
|
2
|
+
require 'subj_models/concerns/shared_scopes'
|
3
|
+
|
4
|
+
module SubjModels
|
5
|
+
|
6
|
+
module BrandLineModule
|
7
|
+
|
8
|
+
def self.included(including_class)
|
9
|
+
|
10
|
+
including_class.class_eval do
|
11
|
+
|
12
|
+
include SubjModels::SharedScopes
|
13
|
+
include SubjModels::ComprisingExternalId
|
14
|
+
|
15
|
+
belongs_to :brand
|
16
|
+
belongs_to :document_file
|
17
|
+
|
18
|
+
has_many :nomenclatures
|
19
|
+
|
20
|
+
validates :name, presence: true
|
21
|
+
|
22
|
+
scope :brand_id, -> (brand) do
|
23
|
+
return all unless brand.present?
|
24
|
+
parent_id_scope("brand", brand)
|
25
|
+
end
|
26
|
+
|
27
|
+
scope :to_show, -> () { where(show_on_index: true) }
|
28
|
+
scope :is_recommended, -> (condition) { where(is_recommended: condition) }
|
29
|
+
|
30
|
+
scope :category_id, -> (category) do
|
31
|
+
return all unless category.present?
|
32
|
+
joins(:brand, nomenclatures: :category).where('categories.id' => category)
|
33
|
+
end
|
34
|
+
|
35
|
+
scope :brand_ids, -> (brand_ids_string) do
|
36
|
+
unless brand_ids_string.blank?
|
37
|
+
joins(:brand).where('brands.id' => brand_ids_string.split(','))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_s
|
46
|
+
name
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'subj_models/concerns/comprising_external_id'
|
2
|
+
|
3
|
+
module SubjModels
|
4
|
+
|
5
|
+
module CategoryModule
|
6
|
+
|
7
|
+
def self.included(including_class)
|
8
|
+
|
9
|
+
including_class.class_eval do
|
10
|
+
|
11
|
+
include SubjModels::ComprisingExternalId
|
12
|
+
|
13
|
+
has_many :nomenclatures
|
14
|
+
|
15
|
+
belongs_to :image, class_name: "DocumentFile"
|
16
|
+
belongs_to :image_big, class_name: "DocumentFile"
|
17
|
+
|
18
|
+
validates :name, presence: true
|
19
|
+
#validates :slug_url, length: { minimum: 4, maximum: 50 }, uniqueness: true, presence: true
|
20
|
+
|
21
|
+
scope :by_slug_url, -> slug_url { where(slug_url: slug_url) }
|
22
|
+
scope :is_public, -> condition { where(is_public: condition) }
|
23
|
+
scope :by_id, -> ids { where(id: ids) }
|
24
|
+
scope :exclude_by_id, -> ids { where.not(id: ids) }
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_s
|
31
|
+
name
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'subj_models/concerns/comprising_external_id'
|
2
|
+
|
3
|
+
module SubjModels
|
4
|
+
|
5
|
+
module CityModule
|
6
|
+
|
7
|
+
def self.included(including_class)
|
8
|
+
|
9
|
+
including_class.class_eval do
|
10
|
+
|
11
|
+
include SubjModels::ComprisingExternalId
|
12
|
+
|
13
|
+
has_and_belongs_to_many :action_banners
|
14
|
+
has_many :offices
|
15
|
+
has_many :users
|
16
|
+
|
17
|
+
validates :name, presence: true, uniqueness: true
|
18
|
+
|
19
|
+
scope :with_office, -> { joins(:offices).where("offices.id IS NOT NULL").group(:id) }
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_s
|
26
|
+
name
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module SubjModels
|
2
|
+
|
3
|
+
module ComprisingExternalId
|
4
|
+
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
validates :external_id, uniqueness: true, allow_nil: true, allow_blank: true
|
9
|
+
scope :external_id, -> id { where(external_id: id) }
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
def find_by_external_or_internal_id(id)
|
14
|
+
if is_integer?(id)
|
15
|
+
self.find(id)
|
16
|
+
else
|
17
|
+
self.find_by!(external_id: id)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def is_integer?(value)
|
22
|
+
return true if value.is_a?(Integer)
|
23
|
+
value.to_i.to_s == value
|
24
|
+
end
|
25
|
+
|
26
|
+
def parent_id_scope(parent, id)
|
27
|
+
if id.is_a?(Array) || is_integer?(id)
|
28
|
+
joins(parent.to_sym).where("#{parent.pluralize}.id = ?", id)
|
29
|
+
else
|
30
|
+
joins(parent.to_sym).where("#{parent.pluralize}.external_id = ?", id)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|