spree_cm_commissioner 2.9.5 → 2.9.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b5fced09e0795a88c5dfc1cd5ef84584dc557c0c8f0c26f0c1ed8f0c62f5b9a
4
- data.tar.gz: 612e81f2f3b4f7e15e6481c9910523fabc9fed36c9b8b265c83bd9fa1834b826
3
+ metadata.gz: f187ec143a0546d2099b322062ef981cac276ced2ef0ae9714bd5d5984040d2c
4
+ data.tar.gz: 1f2a838ce0779597fd0c5b06784b9e0fbb260085457612dcb7e646f61da0482b
5
5
  SHA512:
6
- metadata.gz: 460533fe4a445145c9edd9e4c0fa1c9fa4c4fc6153105f0dea7e9cf2e873e423e6f967ba734931b5206a9309706a40d92c0a0a13b93d3c59bc57d65fc8be023f
7
- data.tar.gz: 5f11f494bc107000bd15cf51a6ba29f43c64436f8803257f793488fce84f8d4549c15057f2c5b169460cc601a9fd5cea86bf5ec044999467fe013f9a5c6e5778
6
+ metadata.gz: 9f722ef15d8fef51009e1da877520831551d33d4c2391036dcd31db1ddc6f485cc0d475b6144843fb660404e7e75ecfb77769a646bc6933378b4eca181cadfaa
7
+ data.tar.gz: 8ef07513d2cb8b65635dfa960b60d84fdbb6d0ad2731cc098f3e99de64901bd3100e80b9a10c0ac1e1243a4c451f2633b93ca3496775f690b10bd6edc2f66369
data/Gemfile.lock CHANGED
@@ -34,7 +34,7 @@ GIT
34
34
  PATH
35
35
  remote: .
36
36
  specs:
37
- spree_cm_commissioner (2.9.5)
37
+ spree_cm_commissioner (2.9.6)
38
38
  activerecord-multi-tenant
39
39
  activerecord_json_validator (~> 2.1, >= 2.1.3)
40
40
  aws-sdk-cloudfront
@@ -9,6 +9,11 @@ module SpreeCmCommissioner
9
9
  store_public_metadata :group_check_in_enabled, :boolean, default: true
10
10
  store_public_metadata :individual_check_in_enabled, :boolean, default: true
11
11
 
12
+ # Cached existence flag, kept in sync by Role's after_commit callback (see role_decorator.rb) —
13
+ # lets User#check_in_group_for skip querying spree_roles for the common case of an event with no
14
+ # check-in groups at all.
15
+ store_public_metadata :has_check_in_groups, :boolean, default: false
16
+
12
17
  # By default, for most events, manual search is allowed for operators.
13
18
  # For certain large events, admin can disable this manually.
14
19
  store_public_metadata :allow_manual_search_for_operator, :boolean, default: true
@@ -36,6 +36,8 @@ module SpreeCmCommissioner
36
36
  # events under the same vendor can each own a "VIP" group.
37
37
  base.validates :presentation, uniqueness: { scope: :vendor_id }, if: -> { vendor_id.present? && !check_in? }
38
38
  base.validates :presentation, uniqueness: { scope: %i[vendor_id event_id] }, if: -> { vendor_id.present? && check_in? }
39
+
40
+ base.after_commit :sync_event_has_check_in_groups_flag, on: %i[create destroy], if: -> { check_in? }
39
41
  end
40
42
 
41
43
  def generate_unique_name
@@ -67,6 +69,15 @@ module SpreeCmCommissioner
67
69
  ids = product_ids.map(&:to_i)
68
70
  check_in_exclude? ? event_product_ids.map(&:to_i) - ids : ids
69
71
  end
72
+
73
+ private
74
+
75
+ # Keeps Taxon#has_check_in_groups? in sync so User#check_in_group_for can skip querying
76
+ # spree_roles for events with none. Recomputes from scratch rather than assuming true/false from
77
+ # the create/destroy alone, since an event can have more than one check-in group.
78
+ def sync_event_has_check_in_groups_flag
79
+ event.update!(has_check_in_groups: event.check_in_groups.exists?)
80
+ end
70
81
  end
71
82
  end
72
83
 
@@ -165,10 +165,12 @@ module SpreeCmCommissioner
165
165
  @check_in_group_cache[event_id] = spree_roles.find_by(role_type: :check_in, event_id: event_id)
166
166
  end
167
167
 
168
- # Whether this user may check in the given guest. Admins and organizers are never restricted by a
169
- # check-in group; otherwise the crew may check in the guest's ticket if their check-in group allows
170
- # it (include/exclude evaluated on that one group).
168
+ # Whether this user may check in the given guest. Events with no check-in groups at all are
169
+ # unrestricted. Otherwise admins and organizers are never restricted; everyone else may check in
170
+ # the guest's ticket only if their check-in group allows it (include/exclude evaluated on that one
171
+ # group).
171
172
  def can_check_in_guest?(guest)
173
+ return true unless guest.event.has_check_in_groups?
172
174
  return true if admin? || organizer?
173
175
 
174
176
  group = check_in_group_for(guest.event_id)
@@ -178,9 +180,10 @@ module SpreeCmCommissioner
178
180
  end
179
181
 
180
182
  # This user's check-in role for the event, used to scope the operator offline export (one role, one
181
- # export — see Exports::OperatorGuestJsonGzip#role). `nil` = unrestricted (admins/organizers, or
182
- # crew in no group).
183
+ # export — see Exports::OperatorGuestJsonGzip#role). `nil` = unrestricted (admins/organizers, crew in
184
+ # no group, or an event with no check-in groups at all — see #can_check_in_guest?).
183
185
  def check_in_role_for(event)
186
+ return nil unless event.has_check_in_groups?
184
187
  return nil if admin? || organizer?
185
188
 
186
189
  check_in_group_for(event.id)
@@ -1,5 +1,5 @@
1
1
  module SpreeCmCommissioner
2
- VERSION = '2.9.5'.freeze
2
+ VERSION = '2.9.6'.freeze
3
3
 
4
4
  module_function
5
5
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_cm_commissioner
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.5
4
+ version: 2.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - You