woody-decorators 10.4.0 → 11.0.0

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: 7e469a5f869b8fb2f508d2772c8de2f6b61f5d70
4
- data.tar.gz: d7fd743dbd2abfe9a20df179dc726123c37a0391
3
+ metadata.gz: 27edffb87d8831036d27ebd91048011987c81ae9
4
+ data.tar.gz: d466b419f5c7ead571b3a0f119dbcc33a2d1d210
5
5
  SHA512:
6
- metadata.gz: bf3c3a4a8fbbb4125fb62b388cebc5c893cfd9f38d11706b7001536e1e8fe9e873935ae16b1f88e352a3aa5b5b7f205df45643a53b3c1b4e001c86e92fa36831
7
- data.tar.gz: e449acc2f1e7eb2d97294cb54416aec032b00c2262d77d9e484e31bcadc99fea899a0daa77c11fffebd1dcfdc907914eaa9efe6d76e22183f49388955518e110
6
+ metadata.gz: d12e4eda5c4613bfb986fa8d59c1de5e83012efb8527a3a673a8b7a0d055691dbaace231506ad35a95fa9081a27dee08f436d1f1ce3614479c8bd4b91b2ee23c
7
+ data.tar.gz: 3638d2a893ba90ec59769c2d7f988a1ae8cab6142b4745bc927bc3835dfa517509df1c2fdbd41dd3683a4b0be1df226515eab0186552f7240072f38ad7e52d61
@@ -9,15 +9,37 @@ module Woody
9
9
  super(model)
10
10
  end
11
11
 
12
- def facebook_account_connected?
13
- !@model.fb_ad_account_id.nil?
14
- end
15
-
16
12
  def briefs
17
13
  @model.briefs.map do |c|
18
14
  Brief.new(c, @config)
19
15
  end
20
16
  end
17
+
18
+ def facebook_account
19
+ find_partner_account('facebook')
20
+ end
21
+
22
+ def facebook_account_connected?
23
+ !facebook_account.nil?
24
+ end
25
+
26
+ def partner_accounts
27
+ @partner_accounts = @model.partner_accounts
28
+ end
29
+
30
+ def snapchat_account
31
+ find_partner_account('snapchat')
32
+ end
33
+
34
+ private
35
+
36
+ def find_partner_account(type)
37
+ partner_accounts.each do |pa|
38
+ return pa if pa.partner_name == type
39
+ end
40
+
41
+ nil
42
+ end
21
43
  end
22
44
  end
23
45
  end
@@ -14,16 +14,42 @@ module Woody
14
14
  super(model)
15
15
  end
16
16
 
17
+ def bonus_reward_pool
18
+ r = @model.rewards
19
+ r ? r.bonus_payment_pool : 0
20
+ end
21
+
17
22
  def brand
18
23
  @brand ||= Woody::Decorators::Brand.new(
19
24
  @model.brands.first, @config
20
25
  )
21
26
  end
22
27
 
28
+ def brand_status
29
+ case @model.category
30
+ when 'brand'
31
+ return 'In Development' if @model.status == 'draft' || @model.end_date.nil?
32
+ return 'Live' if is_live?
33
+ purchased_videos > 0 ? 'Complete' : 'Video Review'
34
+ when 'vidsy', 'squad'
35
+ return 'In Development' if @model.status == 'draft'
36
+ return 'Live'
37
+ end
38
+ end
39
+
40
+ def brand_status_identifier
41
+ brand_status.downcase.gsub(' ', '-')
42
+ end
43
+
23
44
  def concept_questions
24
45
  questions.fetch('concept') { {} }
25
46
  end
26
47
 
48
+ def creator_seats
49
+ r = @model.rewards
50
+ r ? r.creator_seats : 0
51
+ end
52
+
27
53
  def draft?
28
54
  case @model.category
29
55
  when 'brand'
@@ -46,21 +72,15 @@ module Woody
46
72
  end
47
73
  end
48
74
 
49
- def parsed_end_date(submission = nil)
50
- case @model.category
51
- when 'brand'
52
- DateTime.parse(@model.end_date)
53
- when 'vidsy'
54
- DateTime.parse(submission.created_at).advance(hours: @model.duration)
55
- when 'squad'
56
- nil
57
- end
58
- end
59
-
60
75
  def essentials_questions
61
76
  questions.fetch('essentials') { {} }
62
77
  end
63
78
 
79
+ def expense_reward_pool
80
+ r = @model.rewards
81
+ r ? r.expense_payment_pool : 0
82
+ end
83
+
64
84
  def exist?
65
85
  !@model.nil?
66
86
  end
@@ -84,33 +104,47 @@ module Woody
84
104
  )
85
105
  end
86
106
 
87
- def bonus_reward_pool
88
- r = @model.rewards
89
- r ? r.bonus_payment_pool : 0
90
- end
107
+ def insights_post(yml_config, post_id)
108
+ post = @model.insights('posts').find do |p|
109
+ p['post_id'] == post_id
110
+ end
91
111
 
92
- def creator_seats
93
- r = @model.rewards
94
- r ? r.creator_seats : 0
112
+ return nil unless post
113
+
114
+ {
115
+ post: Insights::Hydrator.hydrate(yml_config, post)
116
+ }
95
117
  end
96
118
 
97
- def expense_reward_pool
98
- r = @model.rewards
99
- r ? r.expense_payment_pool : 0
119
+ def insights_posts_list(yml_config)
120
+ {
121
+ posts: Insights::Hydrator.hydrate_array(
122
+ yml_config, sorted_posts
123
+ )
124
+ }
100
125
  end
101
126
 
102
- def time_reward
103
- r = @model.rewards
104
- r ? r.time_payment : 0
127
+ def insights_summary(yml_config)
128
+ {
129
+ summary: Insights::Hydrator.hydrate(
130
+ yml_config, @model.insights('summary')
131
+ )
132
+ }
105
133
  end
106
134
 
107
- def time_reward_pool
108
- r = @model.rewards
109
- r ? (r.time_payment * r.creator_seats) : 0
135
+ def parsed_end_date(submission = nil)
136
+ case @model.category
137
+ when 'brand'
138
+ DateTime.parse(@model.end_date)
139
+ when 'vidsy'
140
+ DateTime.parse(submission.created_at).advance(hours: @model.duration)
141
+ when 'squad'
142
+ nil
143
+ end
110
144
  end
111
145
 
112
- def total_reward_pool
113
- time_reward_pool + bonus_reward_pool
146
+ def public?
147
+ @model.type == 'public'
114
148
  end
115
149
 
116
150
  def status(submission = nil)
@@ -124,22 +158,6 @@ module Woody
124
158
  end
125
159
  end
126
160
 
127
- def brand_status
128
- case @model.category
129
- when 'brand'
130
- return 'In Development' if @model.status == 'draft' || @model.end_date.nil?
131
- return 'Live' if is_live?
132
- purchased_videos > 0 ? 'Complete' : 'Video Review'
133
- when 'vidsy', 'squad'
134
- return 'In Development' if @model.status == 'draft'
135
- return 'Live'
136
- end
137
- end
138
-
139
- def brand_status_identifier
140
- brand_status.downcase.gsub(' ', '-')
141
- end
142
-
143
161
  def time_left(submission = nil)
144
162
  case @model.category
145
163
  when 'brand'
@@ -154,41 +172,41 @@ module Woody
154
172
  format('%s remaining', time_left(submission))
155
173
  end
156
174
 
175
+ def time_reward
176
+ r = @model.rewards
177
+ r ? r.time_payment : 0
178
+ end
179
+
180
+ def time_reward_pool
181
+ r = @model.rewards
182
+ r ? (r.time_payment * r.creator_seats) : 0
183
+ end
184
+
157
185
  def title(truncate: false, size: 15)
158
186
  return @model.title unless @model.title.size >= size && truncate
159
187
  truncate(@model.title, (size - 3))
160
188
  end
161
189
 
162
- def public?
163
- @model.type == 'public'
190
+ def total_reward_pool
191
+ time_reward_pool + bonus_reward_pool
164
192
  end
165
193
 
166
- def insights_post(yml_config, post_id)
167
- post = @model.insights('posts').find do |p|
168
- p['post_id'] == post_id
194
+ def video_has_partner_asset?(video_id, partner = nil)
195
+ video_partner_assets.each do |vpa|
196
+ if vpa.video_id == video_id
197
+ return vpa if partner.nil? || vpa.partner_name == partner
198
+ end
169
199
  end
170
200
 
171
- return nil unless post
172
-
173
- {
174
- post: Insights::Hydrator.hydrate(yml_config, post)
175
- }
176
- end
177
-
178
- def insights_posts_list(yml_config)
179
- {
180
- posts: Insights::Hydrator.hydrate_array(
181
- yml_config, sorted_posts
182
- )
183
- }
201
+ nil
184
202
  end
185
203
 
186
- def insights_summary(yml_config)
187
- {
188
- summary: Insights::Hydrator.hydrate(
189
- yml_config, @model.insights('summary')
190
- )
191
- }
204
+ def video_partner_assets(partner = nil)
205
+ return fetch_video_partner_assets if partner.nil?
206
+
207
+ return fetch_video_partner_assets.select do |vpa|
208
+ vpa.partner_name === partner
209
+ end
192
210
  end
193
211
 
194
212
  private
@@ -201,27 +219,8 @@ module Woody
201
219
  purchased_videos > 0 ? 'Complete' : 'Video Review'
202
220
  end
203
221
 
204
- def vidsy_category_status(submission)
205
- return 'Complete' if ended?(submission)
206
- time_remaining(submission)
207
- end
208
-
209
- def squad_category_status(submission)
210
- case submission.state
211
- when 'pending'
212
- 'Awaiting Approval'
213
- when 'declined'
214
- 'More spaces opening soon!'
215
- when 'approved'
216
- 'Active'
217
- end
218
- end
219
-
220
- def sorted_posts
221
- @model.insights('posts').sort do |a, b|
222
- DateTime.parse(b['data']['created_timestamp']) <=>
223
- DateTime.parse(a['data']['created_timestamp'])
224
- end
222
+ def fetch_video_partner_assets
223
+ @video_partner_assets = @model.video_partner_assets
225
224
  end
226
225
 
227
226
  def is_live?
@@ -229,10 +228,6 @@ module Woody
229
228
  (selected_videos == 0 && purchased_videos == 0)
230
229
  end
231
230
 
232
- def selected_videos
233
- @selected_videos ||= @model.videos(state: 'selected').size
234
- end
235
-
236
231
  def purchased_videos
237
232
  @purchased_videos ||= @model.videos(state: 'purchased').size
238
233
  end
@@ -243,9 +238,36 @@ module Woody
243
238
  end.group_by(&:section)
244
239
  end
245
240
 
241
+ def selected_videos
242
+ @selected_videos ||= @model.videos(state: 'selected').size
243
+ end
244
+
245
+ def sorted_posts
246
+ @model.insights('posts').sort do |a, b|
247
+ DateTime.parse(b['data']['created_timestamp']) <=>
248
+ DateTime.parse(a['data']['created_timestamp'])
249
+ end
250
+ end
251
+
252
+ def squad_category_status(submission)
253
+ case submission.state
254
+ when 'pending'
255
+ 'Awaiting Approval'
256
+ when 'declined'
257
+ 'More spaces opening soon!'
258
+ when 'approved'
259
+ 'Active'
260
+ end
261
+ end
262
+
246
263
  def truncate(s, i)
247
264
  format('%s...', s[0..i])
248
265
  end
266
+
267
+ def vidsy_category_status(submission)
268
+ return 'Complete' if ended?(submission)
269
+ time_remaining(submission)
270
+ end
249
271
  end
250
272
  end
251
273
  end
@@ -49,6 +49,12 @@ module Woody
49
49
  )
50
50
  end
51
51
 
52
+ def processed?
53
+ return true if dev?
54
+ return false unless states?('gif') && states?('mp4')
55
+ type_processed?('gif') && type_processed?('mp4')
56
+ end
57
+
52
58
  def thumbnail
53
59
  return 'https://i.imgur.com/jZCPUYx.gif' if dev?
54
60
  return processing_image unless states?('gif')
@@ -57,22 +63,12 @@ module Woody
57
63
  )
58
64
  end
59
65
 
60
- def processed?
61
- return true if dev?
62
- return false unless states?('gif') && states?('mp4')
63
- type_processed?('gif') && type_processed?('mp4')
64
- end
65
-
66
66
  def url
67
67
  return dev_url if dev?
68
68
  return '' unless states?('mp4')
69
69
  video_transcoding_state('mp4').path(filename_hash)
70
70
  end
71
71
 
72
- def has_facebook_status?
73
- !@model.facebook_status.nil?
74
- end
75
-
76
72
  private
77
73
 
78
74
  def app_config
@@ -1,5 +1,5 @@
1
1
  module Woody
2
2
  module Decorators
3
- VERSION = '10.4.0'.freeze
3
+ VERSION = '11.0.0'.freeze
4
4
  end
5
5
  end
@@ -26,6 +26,6 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency "json", "~> 1"
27
27
  spec.add_dependency "time_diff", "~> 0"
28
28
  spec.add_dependency "wes-cloudkit", "~> 4"
29
- spec.add_dependency "wes-data-api", "~> 12"
29
+ spec.add_dependency "wes-data-api", "~> 13"
30
30
  spec.add_dependency "rinku", "~> 2"
31
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: woody-decorators
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.4.0
4
+ version: 11.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-31 00:00:00.000000000 Z
11
+ date: 2017-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '12'
131
+ version: '13'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '12'
138
+ version: '13'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rinku
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
193
  version: '0'
194
194
  requirements: []
195
195
  rubyforge_project:
196
- rubygems_version: 2.5.2
196
+ rubygems_version: 2.5.1
197
197
  signing_key:
198
198
  specification_version: 4
199
199
  summary: ''