effective_events 0.2.8 → 0.4.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: 14b31d4fcbf22eb2a7a235b42b02db1b5940319f76964200e368a5fb0fe6d5d2
4
- data.tar.gz: 7f157eaa6726be68a1595c4e887aa535ddda2d81936e35d3783f4d598b128aaf
3
+ metadata.gz: 40d63b8ec4a478d2ef2672b209b66f5df68edfc289f263739d07f33a0b756655
4
+ data.tar.gz: 5a98dd988e4703d3c63066a900e39f9898774a26ef8dcf142a9db5d98ee35929
5
5
  SHA512:
6
- metadata.gz: 5339ff0360365f773d2d86c8040eb1ec56cf114a02714bb8189139befe666baf9289bb2ae8c3c15521db13324ba173c23bc57fc74a6973a2cd54f1f9f31a3cc1
7
- data.tar.gz: 69002d95887fc84559d4a5d3de1965c3bb8f9b541ff139c760488d38d4c9c498044dd0b3bd8160cf60bce2567a6fef3bda2e973b8356b37144627c71c7f4c188
6
+ metadata.gz: 4a97bb5b344c9e4ae15768fc809b4838c9f3835069630941c5dad68c668add8e01eaee168ecff600344ae4840a52bb3e58693cc17bfecc65abf82b76b115aae9
7
+ data.tar.gz: '019b4eec4c6aeab11336b1b37b03e645c7f91336876c0937c878eb372cd0894b995d6a32dc4a0d3c8b6edf14791b726f50240431c5f0cb556cf6ee7ec7f5ecf3'
@@ -1,5 +1,10 @@
1
1
  module Admin
2
2
  class EffectiveEventAddonsDatatable < Effective::Datatable
3
+ filters do
4
+ scope :unarchived, label: "All"
5
+ scope :archived
6
+ end
7
+
3
8
  datatable do
4
9
  col :updated_at, visible: false
5
10
  col :created_at, visible: false
@@ -1,5 +1,10 @@
1
1
  module Admin
2
2
  class EffectiveEventProductsDatatable < Effective::Datatable
3
+ filters do
4
+ scope :unarchived, label: "All"
5
+ scope :archived
6
+ end
7
+
3
8
  datatable do
4
9
  reorder :position
5
10
 
@@ -12,8 +17,6 @@ module Admin
12
17
  col :title
13
18
  col :price, as: :price
14
19
 
15
- col :archived
16
-
17
20
  col :capacity_to_s, label: 'Capacity' do |ticket|
18
21
  if ticket.capacity.present?
19
22
  "#{ticket.capacity_available} remaining / #{ticket.capacity} total"
@@ -1,5 +1,10 @@
1
1
  module Admin
2
2
  class EffectiveEventRegistrantsDatatable < Effective::Datatable
3
+ filters do
4
+ scope :unarchived, label: "All"
5
+ scope :archived
6
+ end
7
+
3
8
  datatable do
4
9
  col :updated_at, visible: false
5
10
  col :created_at, visible: false
@@ -1,5 +1,10 @@
1
1
  module Admin
2
2
  class EffectiveEventTicketsDatatable < Effective::Datatable
3
+ filters do
4
+ scope :unarchived, label: "All"
5
+ scope :archived
6
+ end
7
+
3
8
  datatable do
4
9
  reorder :position
5
10
 
@@ -13,8 +18,6 @@ module Admin
13
18
  col :regular_price, as: :price
14
19
  col :early_bird_price, as: :price
15
20
 
16
- col :archived
17
-
18
21
  col :capacity_to_s, label: 'Capacity' do |ticket|
19
22
  if ticket.capacity.present?
20
23
  "#{ticket.capacity_available} remaining / #{ticket.capacity} total"
@@ -3,8 +3,17 @@
3
3
  class EffectiveEventAddonsDatatable < Effective::Datatable
4
4
  datatable do
5
5
 
6
- col :event_product, search: :string, label: 'Product'
6
+ col :event_product, search: :string, label: 'Product' do |er|
7
+ [
8
+ er.event_product.to_s,
9
+ (content_tag(:span, 'Archived', class: 'badge badge-warning') if er.event_product&.archived?)
10
+ ].compact.join('<br>').html_safe
11
+ end
12
+
7
13
  col :price, as: :price
14
+
15
+ col :archived, visible: false
16
+
8
17
  # col :notes
9
18
  # no actions_col
10
19
  end
@@ -3,7 +3,12 @@
3
3
  class EffectiveEventRegistrantsDatatable < Effective::Datatable
4
4
  datatable do
5
5
 
6
- col :event_ticket, search: :string, label: 'Ticket'
6
+ col :event_ticket, search: :string, label: 'Ticket' do |er|
7
+ [
8
+ er.event_ticket.to_s,
9
+ (content_tag(:span, 'Archived', class: 'badge badge-warning') if er.event_ticket&.archived?)
10
+ ].compact.join('<br>').html_safe
11
+ end
7
12
 
8
13
  col :name do |er|
9
14
  "#{er.first_name} #{er.last_name}<br><small>#{mail_to(er.email)}</small>"
@@ -18,6 +23,8 @@ class EffectiveEventRegistrantsDatatable < Effective::Datatable
18
23
  col :price, as: :price
19
24
  col :notes
20
25
 
26
+ col :archived, visible: false
27
+
21
28
  # no actions_col
22
29
  end
23
30
 
@@ -1,30 +1,38 @@
1
1
  module EffectiveEventsHelper
2
2
 
3
- def effective_events_event_tickets_collection(event)
3
+ def effective_events_event_tickets_collection(event, namespace = nil)
4
4
  raise('expected an Effective::Event') unless event.kind_of?(Effective::Event)
5
5
 
6
- event.event_tickets.reject(&:archived?).map do |ticket|
6
+ # Allow an admin to assign archived tickets
7
+ authorized = (namespace == :admin)
8
+ tickets = (authorized ? event.event_tickets : event.event_tickets.reject(&:archived?))
9
+
10
+ tickets.map do |ticket|
7
11
  title = ticket.to_s
8
12
  price = (ticket.price == 0 ? '$0' : price_to_currency(ticket.price))
9
13
  remaining = (ticket.capacity.present? ? "#{ticket.capacity_available} remaining" : nil)
10
14
 
11
15
  label = [title, price, remaining].compact.join(' - ')
12
- disabled = { disabled: :disabled } unless ticket.available?
16
+ disabled = { disabled: :disabled } unless (authorized || ticket.available?)
13
17
 
14
18
  [label, ticket.to_param, disabled].compact
15
19
  end
16
20
  end
17
21
 
18
- def effective_events_event_products_collection(event)
22
+ def effective_events_event_products_collection(event, namespace = nil)
19
23
  raise('expected an Effective::Event') unless event.kind_of?(Effective::Event)
20
24
 
21
- event.event_products.reject(&:archived?).map do |product|
25
+ # Allow an admin to assign archived products
26
+ authorized = (namespace == :admin)
27
+ products = (authorized ? event.event_products : event.event_products.reject(&:archived?))
28
+
29
+ products.map do |product|
22
30
  title = product.to_s
23
31
  price = (product.price == 0 ? '$0' : price_to_currency(product.price))
24
32
  remaining = (product.capacity.present? ? "#{product.capacity_available} remaining" : nil)
25
33
 
26
34
  label = [title, price, remaining].compact.join(' - ')
27
- disabled = { disabled: :disabled } unless product.available?
35
+ disabled = { disabled: :disabled } unless (authorized || product.available?)
28
36
 
29
37
  [label, product.to_param, disabled].compact
30
38
  end
@@ -82,7 +82,7 @@ module Effective
82
82
  scope :events, -> (user: nil, unpublished: false) {
83
83
  scope = all.deep.sorted
84
84
 
85
- if defined?(EffectiveRoles) && EffectivePosts.use_effective_roles
85
+ if defined?(EffectiveRoles) && EffectiveEvents.use_effective_roles
86
86
  scope = scope.for_role(user&.roles)
87
87
  end
88
88
 
@@ -6,6 +6,7 @@
6
6
  module Effective
7
7
  class EventAddon < ActiveRecord::Base
8
8
  acts_as_purchasable
9
+ acts_as_archived
9
10
 
10
11
  log_changes(to: :event) if respond_to?(:log_changes)
11
12
 
@@ -23,6 +24,8 @@ module Effective
23
24
  effective_resource do
24
25
  notes :text
25
26
 
27
+ archived :boolean
28
+
26
29
  # Acts as Purchasable
27
30
  price :integer
28
31
  qb_item_name :string
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Effective
4
4
  class EventProduct < ActiveRecord::Base
5
+ acts_as_archived
6
+
5
7
  belongs_to :event
6
8
 
7
9
  has_many :event_addons
@@ -3,6 +3,7 @@
3
3
  module Effective
4
4
  class EventRegistrant < ActiveRecord::Base
5
5
  acts_as_purchasable
6
+ acts_as_archived
6
7
 
7
8
  log_changes(to: :event) if respond_to?(:log_changes)
8
9
 
@@ -26,6 +27,8 @@ module Effective
26
27
  number :string
27
28
  notes :text
28
29
 
30
+ archived :boolean
31
+
29
32
  # Acts as Purchasable
30
33
  price :integer
31
34
  qb_item_name :string
@@ -81,7 +84,7 @@ module Effective
81
84
  save!
82
85
 
83
86
  order = Effective::Order.new(items: self, user: owner)
84
- order.purchase!(skip_buyer_validations: true, email: false)
87
+ order.mark_as_purchased!
85
88
 
86
89
  true
87
90
  end
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Effective
4
4
  class EventTicket < ActiveRecord::Base
5
+ acts_as_archived
6
+
5
7
  belongs_to :event
6
8
 
7
9
  has_many :event_registrants
@@ -8,6 +8,8 @@
8
8
 
9
9
  = render 'effective/event_addons/fields', f: f, event: event_addon.event
10
10
 
11
+ = f.check_box :archived, label: "Archive this addon. It will be displayed as archived on the owner's event registration"
12
+
11
13
  - if f.object.new_record?
12
14
  = f.submit 'Save and Mark Paid'
13
15
  - else
@@ -8,6 +8,8 @@
8
8
 
9
9
  = render 'effective/event_registrants/fields', f: f, event: event_registrant.event, namespace: :admin
10
10
 
11
+ = f.check_box :archived, label: "Archive this registrant. It will be displayed as archived on the owner's event registration"
12
+
11
13
  - if f.object.new_record?
12
14
  = f.submit 'Save and Mark Paid'
13
15
  - else
@@ -1,5 +1,9 @@
1
1
  = effective_form_with(model: [:admin, event], engine: true) do |f|
2
- = f.rich_text_area :rich_text_excerpt, hint: 'Will be used for the events excerpt on index pages.'
3
- = f.rich_text_area :rich_text_body, hint: 'The main body of your event'
2
+ - if defined?(EffectiveArticleEditor)
3
+ = f.article_editor :rich_text_excerpt, hint: 'Will be used for the events excerpt on index pages.'
4
+ = f.article_editor :rich_text_body, hint: 'The main body of your event'
5
+ - else
6
+ = f.rich_text_area :rich_text_excerpt, hint: 'Will be used for the events excerpt on index pages.'
7
+ = f.rich_text_area :rich_text_body, hint: 'The main body of your event'
4
8
 
5
9
  = f.submit
@@ -2,8 +2,10 @@
2
2
 
3
3
  = effective_form_with(model: [:admin, event], engine: true) do |f|
4
4
  = card("All Steps") do
5
- = f.rich_text_area "rich_text_all_steps_content", label: false,
6
- hint: "displayed on all steps"
5
+ - if defined?(EffectiveArticleEditor)
6
+ = f.article_editor "rich_text_all_steps_content", label: false, hint: "displayed on all steps"
7
+ - else
8
+ = f.rich_text_area "rich_text_all_steps_content", label: false, hint: "displayed on all steps"
7
9
 
8
10
  %hr
9
11
 
@@ -13,7 +15,9 @@
13
15
  - next unless enabled.include?(step)
14
16
 
15
17
  = card("#{title}") do
16
- = f.rich_text_area "rich_text_#{step}_content", label: false,
17
- hint: "displayed on the event registration #{step} wizard step only"
18
+ - if defined?(EffectiveArticleEditor)
19
+ = f.article_editor "rich_text_#{step}_content", label: false, hint: "displayed on the event registration #{step} wizard step only"
20
+ - else
21
+ = f.rich_text_area "rich_text_#{step}_content", label: false, hint: "displayed on the event registration #{step} wizard step only"
18
22
 
19
23
  = f.submit
@@ -3,10 +3,10 @@
3
3
  - if f.object.purchased?
4
4
  = f.static_field :event_ticket, label: 'Purchased ticket'
5
5
  - else
6
- = f.select :event_ticket_id, effective_events_event_tickets_collection(event), label: 'Ticket'
6
+ = f.select :event_ticket_id, effective_events_event_tickets_collection(event, namespace), label: 'Ticket'
7
7
 
8
8
  - if f.object.purchased? && namespace == :admin
9
- = f.select :event_ticket_id, effective_events_event_tickets_collection(event), label: 'Change Ticket', hint: 'Admin only. Change the purchased ticket. This will not create charges, alter the original order, or consider ticket capacity.'
9
+ = f.select :event_ticket_id, effective_events_event_tickets_collection(event, namespace), label: 'Change Ticket', hint: 'Admin only. Change the purchased ticket. This will not create charges, alter the original order, or consider ticket capacity.'
10
10
 
11
11
  .row
12
12
  .col-lg= f.text_field :first_name
@@ -17,7 +17,6 @@
17
17
  %th Registered by
18
18
  %td= event_registration.owner
19
19
 
20
-
21
20
  - if event_registration.orders.present?
22
21
  %tr
23
22
  %th Order
data/config/routes.rb CHANGED
@@ -16,12 +16,29 @@ EffectiveEvents::Engine.routes.draw do
16
16
 
17
17
  namespace :admin do
18
18
  resources :events, except: [:show]
19
- resources :event_tickets, except: [:show]
20
- resources :event_products, except: [:show]
21
- resources :event_registrants, except: [:show]
22
- resources :event_addons, except: [:show]
23
19
  resources :event_registrations, only: [:index, :show]
24
20
  resources :event_notifications, except: [:show]
21
+
22
+ resources :event_tickets, except: [:show] do
23
+ post :archive, on: :member
24
+ post :unarchive, on: :member
25
+ end
26
+
27
+ resources :event_products, except: [:show] do
28
+ post :archive, on: :member
29
+ post :unarchive, on: :member
30
+ end
31
+
32
+ resources :event_registrants, except: [:show] do
33
+ post :archive, on: :member
34
+ post :unarchive, on: :member
35
+ end
36
+
37
+ resources :event_addons, except: [:show] do
38
+ post :archive, on: :member
39
+ post :unarchive, on: :member
40
+ end
41
+
25
42
  end
26
43
 
27
44
  end
@@ -64,6 +64,8 @@ class CreateEffectiveEvents < ActiveRecord::Migration[6.0]
64
64
  t.integer :purchased_order_id
65
65
  t.integer :price
66
66
 
67
+ t.boolean :archived, default: false
68
+
67
69
  t.timestamps
68
70
  end
69
71
 
@@ -99,6 +101,8 @@ class CreateEffectiveEvents < ActiveRecord::Migration[6.0]
99
101
  t.integer :purchased_order_id
100
102
  t.integer :price
101
103
 
104
+ t.boolean :archived, default: false
105
+
102
106
  t.timestamps
103
107
  end
104
108
 
@@ -9,8 +9,10 @@ module EffectiveEvents
9
9
 
10
10
  # Include concern and allow any ActiveRecord object to call it
11
11
  initializer 'effective_events.active_record' do |app|
12
- ActiveSupport.on_load :active_record do
13
- ActiveRecord::Base.extend(EffectiveEventsEventRegistration::Base)
12
+ app.config.to_prepare do
13
+ ActiveSupport.on_load :active_record do
14
+ ActiveRecord::Base.extend(EffectiveEventsEventRegistration::Base)
15
+ end
14
16
  end
15
17
  end
16
18
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveEvents
2
- VERSION = '0.2.8'.freeze
2
+ VERSION = '0.4.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.2.8
4
+ version: 0.4.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: 2022-03-07 00:00:00.000000000 Z
11
+ date: 2022-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails