effective_events 0.22.1 → 0.23.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
  SHA256:
3
- metadata.gz: af4ffee3a1a64a15a48d9e7ff3ce8eecd6b8f5759fccb0c886e9f943fd42f919
4
- data.tar.gz: c184b3851caea22f826b685c4fc2a0db174f1b99a218f59deeb1edaad7a90694
3
+ metadata.gz: b35f3042e9e99875c91066ad1c6cd8c70e601dfc4abc72e0b32632c683523371
4
+ data.tar.gz: db5f82e191ab087d2b052fb2426c0204a2d8ef0e19b2f4a6f4720aed2d6f1d91
5
5
  SHA512:
6
- metadata.gz: 729e826bfdbe9b0287a87b00f2168791c7b861feb2cbd10e678706ea83876d1bdd638f6e6e18c90b8795bf9058b65c8c2396dda7e47901bfe5962e4071678fe7
7
- data.tar.gz: acf5fc1714ad5b37e9ebf9b0aa56dc3eaf83129059d54a5a9cf16da2edb4f2127cb35ca317d521e14fb171717ba2d95851fb7ea7b17aa1df6c81ec041dbf0caf
6
+ metadata.gz: b00e8a6173d55548bbc2b72048b7bab6f724f7655cd6d78dd40eb9bbaa336eba428918b5961882f0d9af1ce688d60aeb2530657bbb1fac24733e43ba0c64552c
7
+ data.tar.gz: 79d0a3ec08ce158f5d65115f4d1f5d516eb2992f384e3b63c25e6026410b8f43134b9605bb811e15c7afae075adf58c73138159754f0e060f012e1a46dff5557
@@ -1,11 +1,12 @@
1
1
  module Admin
2
2
  class EffectiveEventAddonsDatatable < Effective::Datatable
3
3
  filters do
4
- scope :unarchived, label: "All"
5
- scope :purchased
4
+ scope :registered
5
+ scope :purchased_or_created_by_admin, label: 'Purchased'
6
6
  scope :deferred
7
- scope :not_purchased
7
+ scope :not_purchased_not_created_by_admin, label: 'Not Purchased'
8
8
  scope :archived
9
+ scope :all
9
10
  end
10
11
 
11
12
  datatable do
@@ -36,7 +37,7 @@ module Admin
36
37
  end
37
38
 
38
39
  collection do
39
- scope = Effective::EventAddon.deep.registered.includes(:purchased_order, :owner)
40
+ scope = Effective::EventAddon.deep.includes(:purchased_order, :owner)
40
41
 
41
42
  if attributes[:event_id].present?
42
43
  scope = scope.where(event: event)
@@ -30,17 +30,17 @@ module Admin
30
30
  col :capacity, visible: false
31
31
  col :capacity_available, visible: false
32
32
 
33
- col :registered_event_addons, label: 'Registered Names' do |product|
34
- product.registered_event_addons.reject(&:archived?).sort_by(&:to_s).map do |addon|
35
- content_tag(:div, addon.name.to_s, class: 'col-resource_item')
36
- end.join.html_safe
37
- end
38
-
39
- col :purchased_event_addons, label: 'Purchased Names', visible: false do |product|
40
- product.purchased_event_addons.reject(&:archived?).sort_by(&:to_s).map do |addon|
41
- content_tag(:div, addon.name.to_s, class: 'col-resource_item')
42
- end.join.html_safe
43
- end
33
+ # col :registered_event_addons, label: 'Registered Names' do |product|
34
+ # product.registered_event_addons.reject(&:archived?).sort_by(&:to_s).map do |addon|
35
+ # content_tag(:div, addon.name.to_s, class: 'col-resource_item')
36
+ # end.join.html_safe
37
+ # end
38
+
39
+ # col :purchased_event_addons, label: 'Purchased Names', visible: false do |product|
40
+ # product.purchased_event_addons.reject(&:archived?).sort_by(&:to_s).map do |addon|
41
+ # content_tag(:div, addon.name.to_s, class: 'col-resource_item')
42
+ # end.join.html_safe
43
+ # end
44
44
 
45
45
  actions_col
46
46
  end
@@ -1,12 +1,12 @@
1
1
  module Admin
2
2
  class EffectiveEventRegistrantsDatatable < Effective::Datatable
3
3
  filters do
4
- scope :unarchived, label: "All"
5
4
  scope :registered
6
- scope :purchased
5
+ scope :purchased_or_created_by_admin, label: 'Purchased'
7
6
  scope :deferred
8
- scope :not_purchased
7
+ scope :not_purchased_not_created_by_admin, label: 'Not Purchased'
9
8
  scope :archived
9
+ scope :all
10
10
  end
11
11
 
12
12
  datatable do
@@ -60,7 +60,15 @@ module Admin
60
60
  col :organization, visible: false
61
61
 
62
62
  col :orders, visible: false
63
- col :price, as: :price
63
+
64
+ col(:price, as: :price) do |registrant|
65
+ [
66
+ (badge('ADMIN') if registrant.created_by_admin?),
67
+ price_to_currency(registrant.price)
68
+ ].compact.join(' ').html_safe
69
+ end
70
+
71
+ col :created_by_admin, visible: false
64
72
 
65
73
  col :first_name, visible: false
66
74
  col :last_name, visible: false
@@ -37,15 +37,15 @@ module Admin
37
37
  col :category, visible: false
38
38
 
39
39
  col :registered_event_registrants_count, label: 'Registered' do |event|
40
- event.event_registrants.registered.unarchived.count
40
+ event.event_registrants.registered.count
41
41
  end
42
42
 
43
43
  col :purchased_event_registrants_count, label: 'Deferred', visible: false do |event|
44
- event.event_registrants.deferred.unarchived.count
44
+ event.event_registrants.deferred.count
45
45
  end
46
46
 
47
47
  col :purchased_event_registrants_count, label: 'Purchased', visible: false do |event|
48
- event.event_registrants.purchased.unarchived.count
48
+ event.event_registrants.purchased.count
49
49
  end
50
50
 
51
51
 
@@ -141,6 +141,18 @@ module EffectiveEventsEventRegistration
141
141
  end
142
142
  end
143
143
 
144
+ # Validate the same registrant user isn't registered on another registration
145
+ validate(if: -> { current_step == :details }) do
146
+ present_event_registrants.select { |er| er.user.present? }.each do |er|
147
+ existing = Effective::EventRegistrant.unarchived.registered.where(event_ticket: er.event_ticket, user: er.user).where.not(id: er)
148
+
149
+ if existing.present?
150
+ errors.add(:base, "Unable to register #{er.user} for #{er.event_ticket}. They've already been registered")
151
+ er.errors.add(:user_id, "Unable to register #{er.user} for #{er.event_ticket}. They've already been registered")
152
+ end
153
+ end
154
+ end
155
+
144
156
  # Validate all products are available for registration
145
157
  validate(if: -> { current_step == :addons }) do
146
158
  unavailable_event_products.each do |event_product|
@@ -32,6 +32,8 @@ module Effective
32
32
 
33
33
  archived :boolean
34
34
 
35
+ created_by_admin :boolean
36
+
35
37
  # Acts as Purchasable
36
38
  price :integer
37
39
  qb_item_name :string
@@ -42,7 +44,9 @@ module Effective
42
44
 
43
45
  scope :sorted, -> { order(:id) }
44
46
  scope :deep, -> { includes(:event, :event_product) }
45
- scope :registered, -> { purchased_or_deferred }
47
+ scope :registered, -> { purchased_or_deferred.or(where(created_by_admin: true)) }
48
+ scope :purchased_or_created_by_admin, -> { purchased.or(unarchived.where(created_by_admin: true)) }
49
+ scope :not_purchased_not_created_by_admin, -> { not_purchased.where(created_by_admin: false) }
46
50
 
47
51
  before_validation(if: -> { event_registration.present? }) do
48
52
  self.event ||= event_registration.event
@@ -55,6 +55,8 @@ module Effective
55
55
 
56
56
  archived :boolean
57
57
 
58
+ created_by_admin :boolean
59
+
58
60
  # Acts as Purchasable
59
61
  price :integer
60
62
  qb_item_name :string
@@ -69,7 +71,9 @@ module Effective
69
71
 
70
72
  scope :sorted, -> { order(:event_ticket_id, :id) }
71
73
  scope :deep, -> { includes(:event, :event_ticket, :owner) }
72
- scope :registered, -> { where.not(registered_at: nil) }
74
+ scope :registered, -> { unarchived.where.not(registered_at: nil) }
75
+ scope :purchased_or_created_by_admin, -> { purchased.or(unarchived.where(created_by_admin: true)) }
76
+ scope :not_purchased_not_created_by_admin, -> { not_purchased.where(created_by_admin: false) }
73
77
 
74
78
  before_validation(if: -> { event_registration.present? }) do
75
79
  self.event ||= event_registration.event
@@ -114,9 +118,6 @@ module Effective
114
118
  validates :price, presence: true, numericality: { greater_than_or_equal_to: 0 }
115
119
  validates :email, email: true
116
120
 
117
- # This works for persisted and adding a new one. But not adding two at same time in a registration
118
- validates :user_id, uniqueness: { scope: [:event_ticket_id], allow_blank: true, message: 'is already registered for this event ticket' }
119
-
120
121
  # First name, last name and email are always required fields on details
121
122
  validates :first_name, presence: true, if: -> { registrant_validations_enabled? }
122
123
  validates :last_name, presence: true, if: -> { registrant_validations_enabled? }
@@ -95,7 +95,7 @@ module Effective
95
95
  raise('expected except to be an EventRegistration') if except && !except.class.try(:effective_events_event_registration?)
96
96
 
97
97
  event_registrants.select do |er|
98
- (er.registered? || er.selected_not_expired?) && (except.blank? || er.event_registration_id != except.id)
98
+ (er.registered? || er.selected_not_expired?) && (except.blank? || er.event_registration_id != except.id) && !er.archived?
99
99
  end
100
100
  end
101
101
 
@@ -23,6 +23,9 @@
23
23
 
24
24
  = f.check_box :archived, label: "Archive this addon. It will be displayed as archived on the owner's event registration"
25
25
 
26
+ - if f.object.new_record?
27
+ = f.hidden_field :created_by_admin, value: true
28
+
26
29
  - if f.object.new_record?
27
30
  = f.submit 'Save and Mark Registered'
28
31
  - else
@@ -37,4 +37,7 @@
37
37
 
38
38
  = f.check_box :archived, label: "Archive this registrant. It will be displayed as archived on the owner's event registration"
39
39
 
40
+ - if f.object.new_record?
41
+ = f.hidden_field :created_by_admin, value: true
42
+
40
43
  = f.submit 'Save'
@@ -105,6 +105,7 @@ class CreateEffectiveEvents < ActiveRecord::Migration[6.0]
105
105
  t.integer :price
106
106
 
107
107
  t.boolean :archived, default: false
108
+ t.boolean :created_by_admin, default: false
108
109
 
109
110
  t.timestamps
110
111
  end
@@ -146,6 +147,7 @@ class CreateEffectiveEvents < ActiveRecord::Migration[6.0]
146
147
  t.integer :price
147
148
 
148
149
  t.boolean :archived, default: false
150
+ t.boolean :created_by_admin, default: false
149
151
 
150
152
  t.timestamps
151
153
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveEvents
2
- VERSION = '0.22.1'.freeze
2
+ VERSION = '0.23.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_events
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.1
4
+ version: 0.23.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-31 00:00:00.000000000 Z
11
+ date: 2024-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails