effective_events 3.1.0 → 3.2.0

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: 4e37bb52cbe39fa76dbb40c45b4364abbab706a4a872125e11de75a1432c7b62
4
- data.tar.gz: 484e50eafc049ea811ba446638a600ca8d49e17004da1e7a88d4635afe73f30e
3
+ metadata.gz: 40a4145045dd8daf4428a0bc51fa41b0038e740a94638239f4afc03785288757
4
+ data.tar.gz: 1fb48be6ed97c39e23e9b0ac0103bb89df797a11f17f38490a38439d8ba76fd7
5
5
  SHA512:
6
- metadata.gz: 84b97ecbbad1998e51a2ccbe93a2d5bd015e9a6dfa9f5e267db7a9f2aaf8a1668aaa1822c4ba6482f8cc539ae76846a4b2a0128e7654d0923040b662bc1590a6
7
- data.tar.gz: f8ca6e7b250819032b81a8b8459cf7179e9ff0b8ba782902755fae7d3f1c1a9c247edb0bc12b4ea0f45d883828b8b82bc05cc4fb0160a27271966f1fe179480d
6
+ metadata.gz: ba175c474fdc49420da8dfd410445c24fad80d9cde7e69e169718579855a20c2b194469e1ef871e4782fb0e142317595c1d6a21afec283d78640d9bf72b556bb
7
+ data.tar.gz: 9180e93c99df92081432c14449c25970d2e97cd12de99e989d5ef27f99ba4dcd50f60b932497d44e3646b249912013f5322bb39797c262ba12e43328cf65eb73
@@ -18,6 +18,7 @@ module Admin
18
18
  col :id, visible: false
19
19
 
20
20
  col :registered_at
21
+ col :cancelled_at
21
22
 
22
23
  col :event
23
24
 
@@ -30,12 +30,19 @@ module Admin
30
30
  col :published_start_at, label: "Published start", as: :datetime, visible: false
31
31
  col :published_end_at, label: "Published end", as: :datetime, visible: false
32
32
 
33
- # TODO
34
- # col :total_capacity, label: 'Capacity' do |event|
35
- # if event.event_tickets_with_capacity.present?
36
- # "#{event.total_capacity_taken}/#{event.total_capacity}"
37
- # end
38
- # end
33
+ col :total_registered do |event|
34
+ registered = if event.event_tickets_with_capacity.present?
35
+ "#{event.total_registered_non_waitlisted_count}/#{event.total_capacity}"
36
+ elsif event.event_tickets.present?
37
+ "#{event.total_registered}"
38
+ end
39
+
40
+ waitlisted = if event.event_tickets_with_waitlist.present?
41
+ "#{event.total_registered_waitlisted_count} waitlisted"
42
+ end
43
+
44
+ [registered, waitlisted].compact.join(" +")
45
+ end
39
46
 
40
47
  col :excerpt, visible: false
41
48
 
@@ -7,13 +7,15 @@ module Effective
7
7
  helper EffectiveEventsHelper
8
8
  helper EffectiveOrdersHelper
9
9
 
10
+ # We do not send email from this gem, and instead use the effective_orders gem to send the email.
11
+
10
12
  # For the notifications. No longer used.
11
- def event_registrant_purchased(resource, opts = {})
12
- raise('expected an Effective::EventRegistrant') unless resource.kind_of?(Effective::EventRegistrant)
13
+ # def event_registrant_purchased(resource, opts = {})
14
+ # raise('expected an Effective::EventRegistrant') unless resource.kind_of?(Effective::EventRegistrant)
13
15
 
14
- @assigns = assigns_for(resource)
15
- mail(to: resource.email, **headers_for(resource, opts))
16
- end
16
+ # @assigns = assigns_for(resource)
17
+ # mail(to: resource.email, **headers_for(resource, opts))
18
+ # end
17
19
 
18
20
  protected
19
21
 
@@ -22,6 +24,10 @@ module Effective
22
24
  return event_registrant_assigns(resource).merge(event_assigns(resource.event)).merge(event_ticket_assigns(resource.event_ticket))
23
25
  end
24
26
 
27
+ if resource.class.try(:effective_events_event_registration?)
28
+ return event_registration_assigns(resource).merge(event_assigns(resource.event))
29
+ end
30
+
25
31
  raise('unexpected resource')
26
32
  end
27
33
 
@@ -34,7 +40,23 @@ module Effective
34
40
  url: link_to(effective_events.event_url(resource))
35
41
  }
36
42
 
37
- { event: values }
43
+ {
44
+ event: values,
45
+ dashboard_url: link_to(root_url + 'dashboard')
46
+ }
47
+ end
48
+
49
+ def event_registration_assigns(resource)
50
+ raise('expected an event registration') unless resource.class.try(:effective_events_event_registration?)
51
+
52
+ values = {
53
+ owner: resource.owner.to_s,
54
+ email: resource.email,
55
+ cancelled_registrants: resource.event_registrants.select(&:cancelled?).map(&:to_s).join("<br>"),
56
+ url: link_to(effective_events.event_event_registration_url(resource.event, resource))
57
+ }
58
+
59
+ { event_registration: values }
38
60
  end
39
61
 
40
62
  def event_ticket_assigns(resource)
@@ -287,6 +287,29 @@ module EffectiveEventsEventRegistration
287
287
 
288
288
  true
289
289
  end
290
+
291
+ # Called by the event_registrant.cancel_all!
292
+ # Admin action only. Cancels all event registrants
293
+ def cancel!
294
+ event_registrants.reject(&:cancelled?).each do |event_registrant|
295
+ event_registrant.assign_attributes(cancelled_at: Time.zone.now)
296
+ event_registrant.archive!
297
+ end
298
+
299
+ after_commit { send_event_registrants_cancelled_email! }
300
+
301
+ true
302
+ end
303
+
304
+ def uncancel!
305
+ event_registrants.select(&:cancelled?).each do |event_registrant|
306
+ event_registrant.assign_attributes(cancelled_at: nil)
307
+ event_registrant.unarchive!
308
+ end
309
+
310
+ true
311
+ end
312
+
290
313
  end
291
314
 
292
315
  # Instance Methods
@@ -294,6 +317,10 @@ module EffectiveEventsEventRegistration
294
317
  event.present? ? "Event registration - #{event}" : model_name.human
295
318
  end
296
319
 
320
+ def email
321
+ owner&.email
322
+ end
323
+
297
324
  def in_progress?
298
325
  draft? || submitted?
299
326
  end
@@ -533,6 +560,10 @@ module EffectiveEventsEventRegistration
533
560
  submit_order.send_order_emails!
534
561
  end
535
562
 
563
+ def send_event_registrants_cancelled_email!
564
+ submit_order.send_event_registrants_cancelled_email!
565
+ end
566
+
536
567
  def just_let_them_edit_tickets_and_register_anyway?
537
568
  false
538
569
  end
@@ -283,22 +283,33 @@ module Effective
283
283
  start_at
284
284
  end
285
285
 
286
+ # For Events#index column
286
287
  def event_tickets_with_capacity
287
- event_tickets.reject(&:archived?).select { |et| et.capacity.present? }
288
+ event_tickets.select { |et| et.capacity.present? }
288
289
  end
289
290
 
290
- def total_capacity_available
291
- event_tickets_with_capacity.sum { |et| et.capacity_available }
291
+ def event_tickets_with_waitlist
292
+ event_tickets_with_capacity.select { |et| et.waitlist? }
292
293
  end
293
294
 
294
- def total_capacity_taken
295
- event_tickets_with_capacity.sum { |et| et.capacity_taken }
295
+ # Total Registered and not waitlisted count
296
+ def total_registered_non_waitlisted_count
297
+ event_tickets_with_capacity.sum { |et| et.registered_non_waitlisted_count }
298
+ end
299
+
300
+ # Total Registered and waitlisted count
301
+ def total_registered_waitlisted_count
302
+ event_tickets_with_capacity.sum { |et| et.registered_waitlisted_count }
296
303
  end
297
304
 
298
305
  def total_capacity
299
306
  event_tickets_with_capacity.sum { |et| et.capacity }
300
307
  end
301
308
 
309
+ def total_registered
310
+ event_tickets.sum { |et| et.registered_count }
311
+ end
312
+
302
313
  # The amount of tickets that can be purchased except ones from an event registration
303
314
  def capacity_selectable(event_ticket:, event_registration: nil)
304
315
  return 0 if event_ticket.archived?
@@ -47,6 +47,7 @@ module Effective
47
47
 
48
48
  selected_at :datetime # When the event registration was selected by a user on the tickets! step
49
49
  registered_at :datetime # When the order is deferred or purchased
50
+ cancelled_at :datetime # When the registrant was cancelled by an admin. This also archives it.
50
51
 
51
52
  # Question Responses
52
53
  response1 :text
@@ -221,7 +222,8 @@ module Effective
221
222
  (content_tag(:span, 'Member', class: 'badge badge-warning') if member?),
222
223
  (content_tag(:span, 'Guest of Member', class: 'badge badge-warning') if guest_of_member?),
223
224
  (content_tag(:span, 'Waitlist', class: 'badge badge-warning') if waitlisted_not_promoted?),
224
- (content_tag(:span, 'Archived', class: 'badge badge-warning') if archived?)
225
+ (content_tag(:span, 'Archived', class: 'badge badge-warning') if archived? && !cancelled?),
226
+ (content_tag(:span, 'Cancelled', class: 'badge badge-warning') if cancelled?),
225
227
  ].compact.join(' ').html_safe
226
228
  end
227
229
 
@@ -304,7 +306,9 @@ module Effective
304
306
 
305
307
  def selected_not_expired?
306
308
  return false unless EffectiveEvents.EventRegistration.selection_window.present?
307
- selected_at.present? && (selected_at + EffectiveEvents.EventRegistration.selection_window > Time.zone.now)
309
+ return false unless selected_at.present?
310
+
311
+ (selected_at + EffectiveEvents.EventRegistration.selection_window) > Time.zone.now
308
312
  end
309
313
 
310
314
  # Called by an event_registration after_defer and after_purchase
@@ -436,11 +440,43 @@ module Effective
436
440
  end
437
441
 
438
442
  def unarchive!
443
+ assign_attributes(cancelled_at: nil)
444
+
439
445
  super()
440
446
  orders.reject(&:purchased?).each { |order| order.update_purchasable_attributes! }
441
447
  true
442
448
  end
443
449
 
450
+ def cancelled?
451
+ cancelled_at.present?
452
+ end
453
+
454
+ # If this changes a lot, consider effective_events_event_registration.cancel!
455
+ def cancel!
456
+ assign_attributes(cancelled_at: Time.zone.now)
457
+ archive!
458
+
459
+ after_commit { event_registration&.send_event_registrants_cancelled_email! }
460
+
461
+ true
462
+ end
463
+
464
+ # If this changes a lot, consider effective_events_event_registration.uncancel!
465
+ def uncancel!
466
+ assign_attributes(cancelled_at: nil)
467
+ unarchive!
468
+ end
469
+
470
+ def cancel_all!
471
+ raise("expected an event registration") if event_registration.blank?
472
+ event_registration.cancel!
473
+ end
474
+
475
+ def uncancel_all!
476
+ raise("expected an event registration") if event_registration.blank?
477
+ event_registration.uncancel!
478
+ end
479
+
444
480
  def event_ticket_price
445
481
  raise('expected an event') if event.blank?
446
482
  raise('expected an event ticket') if event_ticket.blank?
@@ -18,8 +18,12 @@
18
18
 
19
19
  = tab 'Registrants & Addons' do
20
20
  %h2 Registrants
21
+ - email_template = Effective::EmailTemplate.where(template_name: :event_registrants_cancelled).first!
22
+
21
23
  .mb-4
22
- %small.text-muted Please refresh the page after archiving/unarchiving here to display an accurate Registered count on the Tickets & Products tab
24
+ %small.text-muted Please refresh the page after archiving/unarchiving/cancelling to display an accurate Registered count on the Tickets & Products tab.
25
+ %br
26
+ %small.text-muted Cancelling a registrant will send an email to the event registration owner notifying them that their tickets have been cancelled.
23
27
 
24
28
  - datatable = EffectiveResources.best('Admin::EffectiveEventRegistrantsDatatable').new(event_id: event.id)
25
29
  .mb-4= render_inline_datatable(datatable)
data/config/routes.rb CHANGED
@@ -47,6 +47,11 @@ EffectiveEvents::Engine.routes.draw do
47
47
  post :waitlist, on: :member
48
48
  post :unwaitlist, on: :member
49
49
 
50
+ post :cancel, on: :member
51
+ post :uncancel, on: :member
52
+ post :cancel_all, on: :member
53
+ post :uncancel_all, on: :member
54
+
50
55
  post :archive, on: :member
51
56
  post :unarchive, on: :member
52
57
 
@@ -106,6 +106,7 @@ class CreateEffectiveEvents < ActiveRecord::Migration[6.0]
106
106
 
107
107
  t.datetime :selected_at
108
108
  t.datetime :registered_at
109
+ t.datetime :cancelled_at
109
110
 
110
111
  t.text :response1
111
112
  t.text :response2
@@ -1,3 +1,3 @@
1
1
  module EffectiveEvents
2
- VERSION = '3.1.0'.freeze
2
+ VERSION = '3.2.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: 3.1.0
4
+ version: 3.2.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: 2025-10-07 00:00:00.000000000 Z
11
+ date: 2025-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -300,7 +300,6 @@ files:
300
300
  - app/views/effective/events/_sidebar.html.haml
301
301
  - app/views/effective/events/index.html.haml
302
302
  - app/views/effective/events/show.html.haml
303
- - app/views/effective/events_mailer/event_registrant_purchased.liquid
304
303
  - app/views/simple_calendar/_month_calendar.html.haml
305
304
  - config/effective_events.rb
306
305
  - config/locales/effective_events.en.yml
@@ -1,16 +0,0 @@
1
- ---
2
- subject: 'You have been registered for {{ event.title }}'
3
- ---
4
- Hello {{ registrant.name }},
5
-
6
- Your ticket {{ ticket.name }} has been purchased.
7
-
8
- You are registered for {{ event.name }}
9
-
10
- The event starts on {{ event.date }}
11
-
12
- {{ event.url }}
13
-
14
- Thank you.
15
-
16
- Please contact us for assistance.