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 +4 -4
- data/Gemfile.lock +1 -1
- data/app/models/concerns/spree_cm_commissioner/event_metadata.rb +5 -0
- data/app/models/spree_cm_commissioner/role_decorator.rb +11 -0
- data/app/models/spree_cm_commissioner/user_decorator.rb +8 -5
- 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: f187ec143a0546d2099b322062ef981cac276ced2ef0ae9714bd5d5984040d2c
|
|
4
|
+
data.tar.gz: 1f2a838ce0779597fd0c5b06784b9e0fbb260085457612dcb7e646f61da0482b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9f722ef15d8fef51009e1da877520831551d33d4c2391036dcd31db1ddc6f485cc0d475b6144843fb660404e7e75ecfb77769a646bc6933378b4eca181cadfaa
|
|
7
|
+
data.tar.gz: 8ef07513d2cb8b65635dfa960b60d84fdbb6d0ad2731cc098f3e99de64901bd3100e80b9a10c0ac1e1243a4c451f2633b93ca3496775f690b10bd6edc2f66369
|
data/Gemfile.lock
CHANGED
|
@@ -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.
|
|
169
|
-
#
|
|
170
|
-
# it (include/exclude evaluated on that one
|
|
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,
|
|
182
|
-
#
|
|
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)
|