subj_models 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 83658738a7ab8465ad59311cc0045293dcd9dafd
4
- data.tar.gz: 454ba909f7b04f33c533e5d3dc8379b7ca6fb407
3
+ metadata.gz: ffa0c2a11913afea11257be5d268b5b4efb9bcf8
4
+ data.tar.gz: 7d314c1212c40c3d8edd8551791403c0028e92c9
5
5
  SHA512:
6
- metadata.gz: b8aa9974e7dd80d9409e26c6ed2ff2cf0ce3dc2a81d34870e94dd2c4d14357c0f16e011f759e47b22dba605d9e82a2714cbc46fa73045fc05ff6d7634db5a7ea
7
- data.tar.gz: beea5614269b216341631d6f8e40ae1372d7db27c3f4c49ce59c854cf9b77c545d598dc053a093b36bf34319fc3e3462a14aa08e9b9b30ee992a384f0fcff358
6
+ metadata.gz: 6b5af94dcf10b00680b5262e55f9ba7afec7a8cc3aa20ff42a11d250944a21d4decbbc35a4d6a5c5f1b5541631c58f5341c60133838f558f9e3c46ea84d4b197
7
+ data.tar.gz: d8c6803edd8361cb13aeeb417c684107c06186b6cea9bc5170356d17f25f56d99f0c9a80ac8f4ef5a122216b39f962a6cd3a8eb615937a5c046b54772f993fa1
@@ -12,10 +12,15 @@ module SubjModels
12
12
 
13
13
  has_and_belongs_to_many :cities
14
14
  has_and_belongs_to_many :nomenclatures
15
+ has_and_belongs_to_many :brands
15
16
  belongs_to :image, class_name: "DocumentFile"
16
17
  belongs_to :categories_list_image, class_name: "DocumentFile"
17
18
 
18
- validates :name, :discount_percent, presence: true
19
+ validates :nomenclatures, :brands, :image, 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}
19
24
 
20
25
  scope :to_show, -> condition { where(to_show: condition) }
21
26
 
@@ -18,6 +18,7 @@ module SubjModels
18
18
  has_many :events
19
19
 
20
20
  has_and_belongs_to_many :users
21
+ has_and_belongs_to_many :actions
21
22
 
22
23
  belongs_to :content_block1, class_name: "ContentBlock"
23
24
  belongs_to :content_block2, class_name: "ContentBlock"
@@ -11,6 +11,7 @@ module SubjModels
11
11
  include SubjModels::ComprisingExternalId
12
12
 
13
13
  belongs_to :document_file
14
+ has_one :brand
14
15
 
15
16
  end
16
17
 
@@ -18,8 +19,8 @@ module SubjModels
18
19
 
19
20
  def to_s
20
21
  brands = Brand.where('content_block1_id=? OR (content_block2_id=? OR content_block3_id=?)', id, id, id)
21
-
22
- "#{title} - #{brands.any? ? 'С брендом' : 'Без бренда'}"
22
+ addition_text = brands.any? ? "#{brands.first.try(:name)}" : 'Без бренда'
23
+ "#{title} - " + addition_text
23
24
  end
24
25
 
25
26
  end
@@ -30,7 +30,6 @@ module SubjModels
30
30
  scope :from_today, -> {
31
31
  joins(:event_schedule).where('event_schedules.event_date >= ?', DateTime.now.beginning_of_day )
32
32
  .order( 'event_schedules.event_date ASC' )
33
- # .unscope(:event_schedule)
34
33
  }
35
34
 
36
35
  scope :where_nomenclature_ids, -> (ids) do
@@ -1,3 +1,3 @@
1
1
  module SubjModels
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
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.5.1
4
+ version: 0.5.2
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-24 00:00:00.000000000 Z
11
+ date: 2016-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler