spree_cm_commissioner 2.8.2.pre.pre.6 → 2.8.2.pre.pre.8
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/Gemfile.lock +1 -1
- data/app/models/spree_cm_commissioner/voting_session.rb +20 -0
- data/app/serializers/spree/v2/tenant/voting_session_serializer.rb +2 -2
- data/db/migrate/20260601000000_add_combining_parent_to_cm_voting_sessions.rb +3 -2
- data/lib/spree_cm_commissioner/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5ef384b13b8b23bbd46aa3c9f8f99e8b7b88e9cd78bcf31e44f74534f60b9a8c
|
|
4
|
+
data.tar.gz: 27796cce088d3db3a9ff09332236705ae3430d4f4065b2d3fdede50016987c41
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7a565f861ce630f95e7422771a5e2188084ad4f52fe7f62c62d229b63904a1a03496429aa728a02eef5eb21f26a733899dde2d320cd575c0156fa99892900648
|
|
7
|
+
data.tar.gz: bfcd0620eb133c51d7ca6f9c55b72aff078955b7d27dbd96a5f08c9090cc4ea04812e6eb0df086b377789f80405eae142d4e2ffa44a0187cc76dd74f1a1c2999
|
data/Gemfile.lock
CHANGED
|
@@ -6,6 +6,7 @@ module SpreeCmCommissioner
|
|
|
6
6
|
belongs_to :vendor, class_name: 'Spree::Vendor', optional: false
|
|
7
7
|
belongs_to :show, class_name: 'SpreeCmCommissioner::Show', optional: false
|
|
8
8
|
belongs_to :episode, class_name: 'Spree::Product', optional: false
|
|
9
|
+
belongs_to :parent, class_name: 'SpreeCmCommissioner::VotingSession', optional: true
|
|
9
10
|
|
|
10
11
|
has_one :season, through: :episode, class_name: 'SpreeCmCommissioner::Show', source: :season
|
|
11
12
|
|
|
@@ -30,10 +31,13 @@ module SpreeCmCommissioner
|
|
|
30
31
|
validates :session_key, presence: true, uniqueness: true
|
|
31
32
|
validates :name, :opens_at, :closes_at, :status, presence: true
|
|
32
33
|
validate :closes_after_opens
|
|
34
|
+
validate :closes_at_not_after_parent
|
|
33
35
|
validate :validate_live_stream_url, if: :live_stream_url_changed?
|
|
34
36
|
|
|
35
37
|
before_validation :generate_session_key, on: :create
|
|
36
38
|
before_save :update_live_stream_thumbnail
|
|
39
|
+
after_create :copy_contestants_from_parent, if: -> { pre_vote? && parent.present? }
|
|
40
|
+
after_update :copy_contestants_from_parent, if: -> { pre_vote? && saved_change_to_parent_id? && parent.present? }
|
|
37
41
|
after_update :schedule_counter_reconciliation, if: -> { saved_change_to_status?(from: 'enabled', to: 'closed') }
|
|
38
42
|
# Scopes
|
|
39
43
|
# Uses the database clock (CURRENT_TIMESTAMP) for consistency and to avoid application server clock drift.
|
|
@@ -210,12 +214,28 @@ module SpreeCmCommissioner
|
|
|
210
214
|
self.session_key ||= "#{episode.slug}-#{Time.current.to_i}-#{SecureRandom.hex(8)}"
|
|
211
215
|
end
|
|
212
216
|
|
|
217
|
+
def copy_contestants_from_parent
|
|
218
|
+
parent.voting_contestants.find_each do |vc|
|
|
219
|
+
voting_contestants.find_or_create_by!(show_contestant: vc.show_contestant) do |new_vc|
|
|
220
|
+
new_vc.show_id = show_id
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
|
|
213
225
|
def closes_after_opens
|
|
214
226
|
return unless opens_at && closes_at
|
|
215
227
|
|
|
216
228
|
errors.add(:closes_at, 'must be after opens_at') if closes_at <= opens_at
|
|
217
229
|
end
|
|
218
230
|
|
|
231
|
+
def closes_at_not_after_parent
|
|
232
|
+
return unless parent && closes_at && parent.closes_at
|
|
233
|
+
|
|
234
|
+
return unless closes_at > parent.closes_at
|
|
235
|
+
|
|
236
|
+
errors.add(:closes_at, 'cannot be after parent session closes_at')
|
|
237
|
+
end
|
|
238
|
+
|
|
219
239
|
def parse_json_config(value)
|
|
220
240
|
return {} if value.nil? || value == ''
|
|
221
241
|
return value if value.is_a?(Hash)
|
|
@@ -2,8 +2,8 @@ module Spree
|
|
|
2
2
|
module V2
|
|
3
3
|
module Tenant
|
|
4
4
|
class VotingSessionSerializer < BaseSerializer
|
|
5
|
-
attributes :opens_at, :closes_at, :status, :session_type, :
|
|
6
|
-
:
|
|
5
|
+
attributes :opens_at, :closes_at, :status, :session_type, :live_stream_enabled,
|
|
6
|
+
:live_stream_thumbnail, :live_stream_title, :live_stream_description,
|
|
7
7
|
:position
|
|
8
8
|
|
|
9
9
|
attribute :live_stream_url, &:embedded_live_stream_url
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
class AddCombiningParentToCmVotingSessions < ActiveRecord::Migration[7.0]
|
|
2
2
|
def change
|
|
3
|
-
add_reference :cm_voting_sessions, :
|
|
3
|
+
add_reference :cm_voting_sessions, :parent,
|
|
4
4
|
foreign_key: { to_table: :cm_voting_sessions },
|
|
5
5
|
null: true,
|
|
6
|
-
index: true
|
|
6
|
+
index: true,
|
|
7
|
+
if_not_exists: true
|
|
7
8
|
end
|
|
8
9
|
end
|