effective_events 0.12.5 → 0.13.1

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: 0db42bb64a1639b358488381a0e7e4ca73814f98c41153cdb929063661b0e947
4
- data.tar.gz: ad79f29da0313754aafc31e90a432eefbda54d631062ab9e593448540c6c4a08
3
+ metadata.gz: 3436a306cb79a123bec79007b2730897d0bb3566dc1c0f2dbd6a31c5eb608a74
4
+ data.tar.gz: 91c60cfc2122eae660a4fc5151f395bf9709bf00c0ccec0f50915e3a2c84f3a9
5
5
  SHA512:
6
- metadata.gz: 0ce3f1278268630aab2aec2547f6b9d3ad100b303a42e403b0b1dd93e7be6a21f1f09385f8835147cc768a77d2a8278cf1ca48dab8afbed97df986716a6478e1
7
- data.tar.gz: 15459694c87b8208ba7f6bd7feb53dc66030e5f7c0ccc858e2a90d3dbb7ebe5761ede77ba6900e86ebcc28f1e225b1b3b5f65113860e268eedcd50f2f96a2f76
6
+ metadata.gz: 972bffdad5a0d13913ec5ab267c82308e1808d5217d0717bd2dba5f823f086974678e32e1c93a9d5ca47165941f006e9877748c2290b681711d5527a9661bbfb
7
+ data.tar.gz: c268aa57f91a45d32af129d493ebf5a3dfe7dc4941e47cfb13d1efcf02353ce8c7d2fbea1ba01c073d9f1365e8284d2c00e03355deb7e1791ca997440447615c
@@ -21,13 +21,9 @@ class EffectiveEventRegistrationsDatatable < Effective::Datatable
21
21
  col :orders, action: :show, visible: false, search: :string
22
22
 
23
23
  actions_col(actions: []) do |er|
24
- if er.draft?
25
- dropdown_link_to('Continue', effective_events.event_event_registration_build_path(er.event, er, er.next_step), 'data-turbolinks' => false)
26
- dropdown_link_to('Delete', effective_events.event_event_registration_path(er.event, er), 'data-confirm': "Really delete #{er}?", 'data-method': :delete)
27
- elsif er.submitted?
24
+ if er.draft? || er.submitted?
28
25
  dropdown_link_to('Continue', effective_events.event_event_registration_build_path(er.event, er, er.next_step), 'data-turbolinks' => false)
29
26
  elsif er.completed?
30
-
31
27
  if EffectiveResources.authorized?(self, :update_blank_registrants, er)
32
28
  dropdown_link_to('Continue', effective_events.event_event_registration_path(er.event, er))
33
29
  else
@@ -40,6 +36,11 @@ class EffectiveEventRegistrationsDatatable < Effective::Datatable
40
36
  dropdown_link_to('Register Again', url)
41
37
  end
42
38
  end
39
+
40
+ if EffectiveResources.authorized?(self, :destroy, er)
41
+ dropdown_link_to('Delete', effective_events.event_event_registration_path(er.event, er), 'data-confirm': "Really delete #{er}?", 'data-method': :delete)
42
+ end
43
+
43
44
  end
44
45
  end
45
46
 
@@ -92,6 +92,9 @@ module EffectiveEventsEventRegistration
92
92
  scope :in_progress, -> { where(status: [:draft, :submitted]) }
93
93
  scope :done, -> { where(status: :completed) }
94
94
 
95
+ scope :delayed, -> { where(event_id: Effective::Event.delayed) }
96
+ scope :not_delayed, -> { where.not(event_id: Effective::Event.delayed) }
97
+
95
98
  scope :for, -> (user) { where(owner: user) }
96
99
 
97
100
  # All Steps validations
@@ -125,19 +128,25 @@ module EffectiveEventsEventRegistration
125
128
  # If we're submitted. Try to move to completed.
126
129
  before_save(if: -> { submitted? }) { try_completed! }
127
130
 
128
- def future_payment_date?
129
- false
131
+ def delayed_payment_date_upcoming?
132
+ event&.delayed_payment_date_upcoming?
130
133
  end
131
134
 
132
135
  def can_visit_step?(step)
133
136
  return false if step == :complete && !completed?
134
137
  return true if step == :complete && completed?
135
138
 
136
- # If they submitted payment with a deferred processor then lock down the steps.
137
- if submitted? && !future_payment_date?
139
+ # If submitted with a cheque/phone deferred (but not delayed) processor then lock down the steps.
140
+ if submitted? && !delayed_payment_date_upcoming?
138
141
  return (step == :submitted)
139
142
  end
140
143
 
144
+ # Add ability to edit registrations up until payment date
145
+ if submitted? && delayed_payment_date_upcoming?
146
+ return can_revisit_completed_steps(step)
147
+ end
148
+
149
+ # Default
141
150
  can_revisit_completed_steps(step)
142
151
  end
143
152
 
@@ -150,6 +159,10 @@ module EffectiveEventsEventRegistration
150
159
  with_outstanding_coupon_fees(submit_fees)
151
160
  end
152
161
 
162
+ def delayed_payment_attributes
163
+ { delayed_payment: event&.delayed_payment, delayed_payment_date: event&.delayed_payment_date }
164
+ end
165
+
153
166
  # All Fees and Orders
154
167
  def submit_fees
155
168
  if defined?(EffectiveMemberships)
@@ -186,6 +199,16 @@ module EffectiveEventsEventRegistration
186
199
  completed?
187
200
  end
188
201
 
202
+ def tickets!
203
+ after_commit { update_submit_fees_and_order! } if submit_order.present?
204
+ save!
205
+ end
206
+
207
+ def addons!
208
+ after_commit { update_submit_fees_and_order! } if submit_order.present?
209
+ save!
210
+ end
211
+
189
212
  def try_completed!
190
213
  return false unless submitted?
191
214
  return false unless submit_order&.purchased?
@@ -221,12 +244,7 @@ module EffectiveEventsEventRegistration
221
244
  if event_registrants.blank?
222
245
  raise('expected owner and event to be present') unless owner && event
223
246
 
224
- event_registrants.build(
225
- first_name: owner.try(:first_name),
226
- last_name: owner.try(:last_name),
227
- email: owner.try(:email),
228
- company: owner.try(:company)
229
- )
247
+ event_registrants.build()
230
248
  end
231
249
 
232
250
  event_registrants
@@ -68,6 +68,10 @@ module Effective
68
68
 
69
69
  allow_blank_registrants :boolean
70
70
 
71
+ # Delayed Payments feature
72
+ delayed_payment :boolean
73
+ delayed_payment_date :date
74
+
71
75
  # Access
72
76
  roles_mask :integer
73
77
  authenticate_user :boolean
@@ -127,14 +131,23 @@ module Effective
127
131
  scope
128
132
  }
129
133
 
134
+ scope :delayed, -> { where(delayed_payment: true).where.not(delayed_payment_date: nil) }
135
+ scope :delayed_payment_date_past, -> { delayed.where(arel_table[:delayed_payment_date].lteq(Time.zone.today)) }
136
+ scope :delayed_payment_date_upcoming, -> { delayed.where(arel_table[:delayed_payment_date].gt(Time.zone.today)) }
137
+
130
138
  validates :title, presence: true, length: { maximum: 255 }
131
139
  validates :published_at, presence: true, unless: -> { draft? }
132
140
  validates :start_at, presence: true
133
141
  validates :end_at, presence: true
142
+ validates :external_registration_url, url: true
134
143
 
135
144
  validates :registration_start_at, presence: true, unless: -> { external_registration? }
136
145
  validates :registration_end_at, presence: true, unless: -> { external_registration? }
137
146
 
147
+ validates :delayed_payment, inclusion: { in: [false], message: "cannot be used for external registration events" }, if: -> { external_registration? }
148
+ validates :delayed_payment_date, presence: true, if: -> { delayed_payment? }
149
+ validates :delayed_payment_date, absence: true, unless: -> { delayed_payment? }
150
+
138
151
  validate(if: -> { start_at && end_at }) do
139
152
  errors.add(:end_at, 'must be after start date') unless start_at < end_at
140
153
  end
@@ -151,6 +164,14 @@ module Effective
151
164
  errors.add(:early_bird_end_at, 'must be before start date') unless early_bird_end_at < start_at
152
165
  end
153
166
 
167
+ validate(if: -> { delayed_payment? }) do
168
+ errors.add(:delayed_payment, 'no delayed payment processor available') unless EffectiveOrders.try(:delayed?)
169
+ end
170
+
171
+ validate(if: -> { delayed_payment_date && registration_end_at }) do
172
+ errors.add(:delayed_payment_date, 'must be after registration end date') unless registration_end_at < delayed_payment_date
173
+ end
174
+
154
175
  validate(if: -> { file.attached? }) do
155
176
  errors.add(:file, 'must be an image') unless file.image?
156
177
  end
@@ -266,5 +287,14 @@ module Effective
266
287
  (registered + quantity) <= event_product.capacity
267
288
  end
268
289
 
290
+ def delayed?
291
+ delayed_payment? && delayed_payment_date.present?
292
+ end
293
+
294
+ def delayed_payment_date_upcoming?
295
+ return false unless delayed?
296
+ delayed_payment_date > Time.zone.now.to_date
297
+ end
298
+
269
299
  end
270
300
  end
@@ -16,11 +16,6 @@
16
16
  - datatable = Admin::EffectiveEventProductsDatatable.new(event_id: event.id)
17
17
  = render_inline_datatable(datatable)
18
18
 
19
- -# = tab 'Registrations' do
20
- -# %h2 Registrations
21
- -# - datatable = Admin::EffectiveEventRegistrationsDatatable.new(event_id: event.id)
22
- -# .mb-4= render_inline_datatable(datatable)
23
-
24
19
  = tab 'Registrants & Addons' do
25
20
  %h2 Registrants
26
21
  .mb-4
@@ -22,19 +22,36 @@
22
22
  .col-md-6= f.datetime_field :start_at, label: "Event Start"
23
23
  .col-md-6= f.datetime_field :end_at, label: "Event End"
24
24
 
25
- %h2 Registration
26
- %p The online registration and purchase for this event will be available between:
27
- = f.datetime_field :registration_start_at, label: "Registration Start"
28
- = f.datetime_field :registration_end_at, label: "Registration End"
29
- = f.datetime_field :early_bird_end_at, label: "Early Bird End",
30
- hint: 'Event tickets can be purchased for early bird pricing before this date. Afterwards regular pricing applies.'
25
+ %hr
31
26
 
32
- = f.check_box :allow_blank_registrants, label: "Yes, allow blank ticket registrations", hint: "Allow event tickets to be purchased without adding a name. The purchaser may return to add names later."
27
+ .row
28
+ .col-md-6
29
+ %h2 Registration
30
+ %p The online registration and purchase for this event will be available between:
31
+ = f.datetime_field :registration_start_at, label: "Registration Start"
32
+ = f.datetime_field :registration_end_at, label: "Registration End"
33
+ = f.datetime_field :early_bird_end_at, label: "Early Bird End",
34
+ hint: 'Event tickets can be purchased for early bird pricing before this date. Afterwards regular pricing applies.'
35
+
36
+ = f.check_box :allow_blank_registrants, label: "Yes, allow blank ticket registrations", hint: "Allow event tickets to be purchased without adding a name. The purchaser may return to add names later."
37
+
38
+ = f.check_box :external_registration, label: "Yes, the registration for this event is handled by another website"
39
+
40
+ = f.show_if(:external_registration, true) do
41
+ = f.url_field :external_registration_url, hint: "The url for external event registration. Must start with http(s)://"
42
+
43
+ .col-md-6
44
+ - if EffectiveOrders.try(:delayed?)
45
+ %h2 Delayed Payments
46
+ %p The online payment for this event will be charged as follows:
47
+
48
+ = f.check_box :delayed_payment, label: "Yes, this is a delayed payment event", hint: "Allow registrations for this event without paying immediately.<br>A secure token representing their credit card will be saved and charged automatically on the following payment date."
33
49
 
34
- = f.check_box :external_registration, label: "Yes, the registration for this event is handled by another website"
50
+ = f.hide_if(:delayed_payment, true) do
51
+ = f.hidden_field :delayed_payment_date, value: ''
35
52
 
36
- = f.show_if(:external_registration, true) do
37
- = f.url_field :external_registration_url, hint: "The url for external event registration. Must start with http(s)://"
53
+ = f.show_if(:delayed_payment, true) do
54
+ = f.date_field :delayed_payment_date, label: "Delayed Payment Charge Date", hint: "The date that the credit card will be charged. Expects a date in the future, after the registration end date. Changing this date will not affect previously generated event registration delayed payment orders."
38
55
 
39
56
  = f.submit do
40
57
  = f.save 'Save'
@@ -22,6 +22,8 @@
22
22
  = f.check_box :member_registrant, label: 'Yes, this ticket will be for a member'
23
23
 
24
24
  = f.show_if(:blank_registrant, false, nested: true) do
25
+ %hr
26
+
25
27
  - if ticket.regular?
26
28
  = render('effective/event_registrants/fields_regular', f: f)
27
29
  - elsif ticket.member_only?
@@ -1,6 +1,6 @@
1
1
  - # Choose member
2
2
  = f.hidden_field :user_type, value: current_user.class.name
3
- = f.select :user_id, effective_events_event_registrant_user_collection(f.object), required: true, hint: effective_events_event_registrant_user_hint()
3
+ = f.select :user_id, effective_events_event_registrant_user_collection(f.object), hint: effective_events_event_registrant_user_hint()
4
4
 
5
5
  = f.show_if(:user_id, '', nested: true) do
6
6
  %p.text-center - or -
@@ -6,17 +6,34 @@
6
6
  - if registration.present?
7
7
  %h2 In Progress Event Registrations
8
8
 
9
- %p
10
- Your registration for
11
- = link_to(registration.event, effective_events.event_path(registration.event))
12
- is incomplete
13
-
14
- %p
15
- Please
16
- = link_to("Continue registration for #{registration.event}", effective_events.event_event_registration_build_path(registration.event, registration, registration.next_step), 'data-turbolinks' => false, class: 'btn btn-primary')
17
- or you can
18
- = link_to('Abandon registration', effective_events.event_event_registration_path(registration.event, registration), 'data-confirm': "Really delete #{registration}?", 'data-method': :delete, class: 'btn btn-danger')
19
- to register for another event.
9
+ - if registration.draft?
10
+ %p
11
+ Your registration for
12
+ = link_to(registration.event, effective_events.event_path(registration.event))
13
+ is incomplete
14
+
15
+ %p
16
+ Please
17
+ = link_to("Continue registration for #{registration.event}", effective_events.event_event_registration_build_path(registration.event, registration, registration.next_step), 'data-turbolinks' => false, class: 'btn btn-primary')
18
+ or you can
19
+ = link_to('Abandon registration', effective_events.event_event_registration_path(registration.event, registration), 'data-confirm': "Really delete registration for #{registration.event}?", 'data-method': :delete, class: 'btn btn-danger')
20
+ to register for another event.
21
+
22
+ - if registration.submitted?
23
+ %p
24
+ Your registration for
25
+ = link_to(registration.event, effective_events.event_path(registration.event))
26
+ has been submitted. You're all done!
27
+
28
+ - if registration.submitted? && registration.event.delayed_payment_date_upcoming?
29
+ %p= registration.submit_order.delayed_payment_info
30
+
31
+ - if registration.submitted? && registration.event.delayed_payment_date_upcoming? && registration.can_visit_step?(:tickets)
32
+ %p
33
+ You can #{link_to('change your registration', effective_events.event_event_registration_build_path(registration.event, registration, :tickets))} until the payment date
34
+ or
35
+ = link_to('abandon registration', effective_events.event_event_registration_path(registration.event, registration), 'data-confirm': "Really delete registration for #{registration.event}?", 'data-method': :delete)
36
+ to cancel and register for another event.
20
37
 
21
38
  %hr
22
39
 
@@ -23,3 +23,8 @@
23
23
  %td
24
24
  - event_registration.orders.each do |order|
25
25
  = link_to(order, effective_orders.order_path(order))
26
+
27
+ - if event_registration.event.delayed?
28
+ %tr
29
+ %th Payment Date
30
+ %td= event_registration.event.delayed_payment_date.strftime('%F')
@@ -16,4 +16,8 @@
16
16
  = f.has_many :event_addons, f.object.build_event_addons do |fp|
17
17
  = render('effective/event_addons/fields', f: fp, event: f.object.event)
18
18
 
19
+ - if resource.delayed_payment_date_upcoming? && resource.submit_order.present?
20
+ .alert.alert-info If the price of your registration changes, your order will be automatically updated.
21
+
22
+ %hr
19
23
  = f.save 'Save and Continue'
@@ -2,9 +2,8 @@
2
2
  = render 'effective/event_registrations/content', resource: resource
3
3
 
4
4
  - if resource.submit_order.deferred?
5
- .card
6
- .card-body
7
- = render_checkout_step2(resource.submit_order, purchased_url: wizard_path(:complete), deferred_url: wizard_path(:submitted), declined_url: wizard_path(:checkout))
5
+ = card do
6
+ = render_checkout_step2(resource.submit_order, purchased_url: wizard_path(:complete), deferred_url: wizard_path(:submitted), declined_url: wizard_path(:checkout))
8
7
  - elsif resource.event.registerable? == false
9
8
  .alert.alert-danger Your selected event is no longer available for registration.
10
9
  - elsif resource.unavailable_event_tickets.present?
@@ -12,7 +11,10 @@
12
11
  - elsif resource.unavailable_event_products.present?
13
12
  .alert.alert-danger Your selected number of event add-ons are no longer available.
14
13
  - else
15
- .card
16
- .card-body
17
- = render_checkout_step2(resource.submit_order, purchased_url: wizard_path(:complete), deferred_url: wizard_path(:submitted), declined_url: wizard_path(:checkout))
14
+ = card do
15
+ = render_checkout_step2(resource.submit_order, purchased_url: wizard_path(:complete), deferred_url: wizard_path(:submitted), declined_url: wizard_path(:checkout))
16
+
17
+
18
+ - if resource.submit_order.delayed? && resource.submit_order.deferred?
19
+ = link_to 'Save and Continue', wizard_path(:submitted), class: 'btn btn-primary'
18
20
 
@@ -4,6 +4,9 @@
4
4
  - raise('expected a submitted event_registration') unless resource.submitted?
5
5
  - raise('expected a deffered event_registration submit_order') unless resource.submit_order&.deferred?
6
6
 
7
+ - if resource.event.delayed?
8
+ - raise('expected event delayed_payment_date to match order delayed_payment_date') unless resource.event.delayed_payment_date == resource.submit_order.delayed_payment_date
9
+
7
10
  .mb-4
8
11
  = link_to "Return to Dashboard", return_to_dashboard_path, class: 'btn btn-lg btn-primary btn-block'
9
12
 
@@ -14,6 +17,15 @@
14
17
  %h3 Incomplete Ticket Information
15
18
  = render 'effective/event_registrations/form_blank_registrants', event_registration: resource
16
19
 
20
+ - if resource.delayed_payment_date_upcoming? && resource.can_visit_step?(:tickets)
21
+ - order = resource.submit_order
22
+
23
+ = card do
24
+ %h3 All done
25
+ %p Your registration for #{resource.event} has been submitted. You're all done!
26
+ %p= resource.submit_order.delayed_payment_info
27
+ %p You can #{link_to('change your registration', wizard_path(:tickets))} until the payment date.
28
+
17
29
  = render 'effective/event_registrations/event_registration', event_registration: resource
18
30
  = render 'effective/event_registrations/orders', event_registration: resource
19
31
 
@@ -9,4 +9,8 @@
9
9
  = f.has_many :event_registrants, f.object.build_event_registrants do |fr|
10
10
  = render('effective/event_registrants/fields', f: fr, event: f.object.event, namespace: :events)
11
11
 
12
+ - if resource.delayed_payment_date_upcoming? && resource.submit_order.present?
13
+ .alert.alert-info If the price of your registration changes, your order will be automatically updated.
14
+
15
+ %hr
12
16
  = f.save 'Save and Continue'
@@ -27,6 +27,9 @@ class CreateEffectiveEvents < ActiveRecord::Migration[6.0]
27
27
  t.integer :roles_mask
28
28
  t.boolean :authenticate_user, default: false
29
29
 
30
+ t.boolean :delayed_payment, default: false
31
+ t.date :delayed_payment_date
32
+
30
33
  t.timestamps
31
34
  end
32
35
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveEvents
2
- VERSION = '0.12.5'.freeze
2
+ VERSION = '0.13.1'.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.12.5
4
+ version: 0.13.1
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-05-27 00:00:00.000000000 Z
11
+ date: 2024-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails