effective_events 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +97 -0
  4. data/Rakefile +18 -0
  5. data/app/assets/config/effective_events_manifest.js +3 -0
  6. data/app/assets/javascripts/effective_events/base.js +0 -0
  7. data/app/assets/javascripts/effective_events.js +1 -0
  8. data/app/assets/stylesheets/effective_events/base.scss +0 -0
  9. data/app/assets/stylesheets/effective_events.scss +1 -0
  10. data/app/controllers/admin/event_registrants_controller.rb +11 -0
  11. data/app/controllers/admin/event_registrations_controller.rb +19 -0
  12. data/app/controllers/admin/event_tickets_controller.rb +8 -0
  13. data/app/controllers/admin/events_controller.rb +18 -0
  14. data/app/controllers/effective/event_registrations_controller.rb +53 -0
  15. data/app/controllers/effective/events_controller.rb +47 -0
  16. data/app/datatables/admin/effective_event_registrants_datatable.rb +47 -0
  17. data/app/datatables/admin/effective_event_registrations_datatable.rb +25 -0
  18. data/app/datatables/admin/effective_event_tickets_datatable.rb +42 -0
  19. data/app/datatables/admin/effective_events_datatable.rb +51 -0
  20. data/app/datatables/effective_event_registrants_datatable.rb +50 -0
  21. data/app/datatables/effective_event_registrations_datatable.rb +35 -0
  22. data/app/datatables/effective_events_datatable.rb +42 -0
  23. data/app/helpers/effective_events_helper.rb +18 -0
  24. data/app/models/concerns/effective_events_event_registration.rb +231 -0
  25. data/app/models/effective/event.rb +181 -0
  26. data/app/models/effective/event_registrant.rb +85 -0
  27. data/app/models/effective/event_registration.rb +7 -0
  28. data/app/models/effective/event_ticket.rb +59 -0
  29. data/app/views/admin/event_registrants/_form.html.haml +14 -0
  30. data/app/views/admin/event_tickets/_form.html.haml +7 -0
  31. data/app/views/admin/events/_form.html.haml +27 -0
  32. data/app/views/admin/events/_form_access.html.haml +10 -0
  33. data/app/views/admin/events/_form_content.html.haml +5 -0
  34. data/app/views/admin/events/_form_event.html.haml +24 -0
  35. data/app/views/admin/events/_form_event_registration_content.html.haml +19 -0
  36. data/app/views/effective/event_registrants/_fields.html.haml +19 -0
  37. data/app/views/effective/event_registrations/_content.html.haml +10 -0
  38. data/app/views/effective/event_registrations/_dashboard.html.haml +30 -0
  39. data/app/views/effective/event_registrations/_event_registration.html.haml +8 -0
  40. data/app/views/effective/event_registrations/_layout.html.haml +3 -0
  41. data/app/views/effective/event_registrations/_orders.html.haml +4 -0
  42. data/app/views/effective/event_registrations/_registrants.html.haml +10 -0
  43. data/app/views/effective/event_registrations/_summary.html.haml +29 -0
  44. data/app/views/effective/event_registrations/billing.html.haml +14 -0
  45. data/app/views/effective/event_registrations/checkout.html.haml +6 -0
  46. data/app/views/effective/event_registrations/registrants.html.haml +14 -0
  47. data/app/views/effective/event_registrations/start.html.haml +18 -0
  48. data/app/views/effective/event_registrations/submitted.html.haml +15 -0
  49. data/app/views/effective/event_registrations/summary.html.haml +8 -0
  50. data/app/views/effective/event_tickets/_fields.html.haml +4 -0
  51. data/app/views/effective/events/_dashboard.html.haml +14 -0
  52. data/app/views/effective/events/_event.html.haml +23 -0
  53. data/app/views/effective/events/_layout.html.haml +1 -0
  54. data/app/views/effective/events/_spacer.html.haml +1 -0
  55. data/app/views/effective/events/index.html.haml +8 -0
  56. data/app/views/effective/events/show.html.haml +16 -0
  57. data/config/effective_events.rb +17 -0
  58. data/config/routes.rb +24 -0
  59. data/db/migrate/01_create_effective_events.rb.erb +98 -0
  60. data/db/seeds.rb +45 -0
  61. data/lib/effective_events/engine.rb +18 -0
  62. data/lib/effective_events/version.rb +3 -0
  63. data/lib/effective_events.rb +21 -0
  64. data/lib/generators/effective_events/install_generator.rb +30 -0
  65. data/lib/generators/templates/effective_events_mailer_preview.rb +4 -0
  66. data/lib/tasks/effective_events_tasks.rake +8 -0
  67. metadata +262 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3286a2f4da1e484f185381cdbf1364c6d966825493a24694c60f7f2da84756b7
4
+ data.tar.gz: d8fdf171da09d771b7f0068071e526df263134cab9666e663e6828f0df1e91c1
5
+ SHA512:
6
+ metadata.gz: f197f262daafb0496e7bf4b07c1bd339eac4ae2b921a6d98d57e1063242f5a901131233dda5626fe907faa39bb033daaacf3231c677b550e549e99c33426a0f3
7
+ data.tar.gz: 2c09ff365be81a9dfb9f9bab9dd93a9bb66fdcb260ce5a1998d2f61a5e5b21dd3c2db63f83dd37cf8cbb2a8cfecf1f521a6e4fbb76842b037054a3d5a85c3301
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2021 Code and Effect Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,97 @@
1
+ # Effective Events
2
+
3
+ Events, event registrants, event tickets and event products.
4
+
5
+ ## Getting Started
6
+
7
+ This requires Rails 6+ and Twitter Bootstrap 4 and just works with Devise.
8
+
9
+ Please first install the [effective_datatables](https://github.com/code-and-effect/effective_datatables) gem.
10
+
11
+ Please download and install the [Twitter Bootstrap4](http://getbootstrap.com)
12
+
13
+ Add to your Gemfile:
14
+
15
+ ```ruby
16
+ gem 'haml-rails' # or try using gem 'hamlit-rails'
17
+ gem 'effective_events'
18
+ ```
19
+
20
+ Run the bundle command to install it:
21
+
22
+ ```console
23
+ bundle install
24
+ ```
25
+
26
+ Then run the generator:
27
+
28
+ ```ruby
29
+ rails generate effective_events:install
30
+ ```
31
+
32
+ The generator will install an initializer which describes all configuration options and creates a database migration.
33
+
34
+ If you want to tweak the table names, manually adjust both the configuration file and the migration now.
35
+
36
+ Then migrate the database:
37
+
38
+ ```ruby
39
+ rake db:migrate
40
+ ```
41
+
42
+ Use the following datatables to display to your user the events:
43
+
44
+ ```haml
45
+ %h2 Events
46
+ - datatable = EffectiveEventsDatatable.new
47
+ ```
48
+
49
+ and
50
+
51
+ ```
52
+ Add a link to the admin menu:
53
+
54
+ ```haml
55
+ - if can? :admin, :effective_events
56
+ - if can? :index, Effective::Event
57
+ = nav_link_to 'Events', effective_events.admin_events_path
58
+ ```
59
+
60
+ ## Configuration
61
+
62
+ ## Authorization
63
+
64
+ All authorization checks are handled via the effective_resources gem found in the `config/initializers/effective_resources.rb` file.
65
+
66
+ ## Permissions
67
+
68
+ The permissions you actually want to define are as follows (using CanCan):
69
+
70
+ ```ruby
71
+ can :index, Effective::Event
72
+
73
+ if user.admin?
74
+ can :manage, Effective::Event
75
+ end
76
+ ```
77
+
78
+ ## License
79
+
80
+ MIT License. Copyright [Code and Effect Inc.](http://www.codeandeffect.com/)
81
+
82
+ ## Testing
83
+
84
+ Run tests by:
85
+
86
+ ```ruby
87
+ rails test
88
+ ```
89
+
90
+ ## Contributing
91
+
92
+ 1. Fork it
93
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
94
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
95
+ 4. Push to the branch (`git push origin my-new-feature`)
96
+ 5. Bonus points for test coverage
97
+ 6. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
6
+ load "rails/tasks/statistics.rake"
7
+
8
+ require "bundler/gem_tasks"
9
+
10
+ require "rake/testtask"
11
+
12
+ Rake::TestTask.new(:test) do |t|
13
+ t.libs << 'test'
14
+ t.pattern = 'test/**/*_test.rb'
15
+ t.verbose = false
16
+ end
17
+
18
+ task default: :test
@@ -0,0 +1,3 @@
1
+ //= link_directory ../javascripts .js
2
+ //= link_directory ../stylesheets .css
3
+ //= link_tree ../images
File without changes
@@ -0,0 +1 @@
1
+ //= require_tree ./effective_events
File without changes
@@ -0,0 +1 @@
1
+ @import 'effective_events/base';
@@ -0,0 +1,11 @@
1
+ module Admin
2
+ class EventRegistrantsController < ApplicationController
3
+ before_action(:authenticate_user!) if defined?(Devise)
4
+ before_action { EffectiveResources.authorize!(self, :admin, :effective_events) }
5
+
6
+ include Effective::CrudController
7
+
8
+ submit :mark_paid, 'Save and Mark Paid'
9
+
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ module Admin
2
+ class EventRegistrationsController < ApplicationController
3
+ before_action(:authenticate_user!) if defined?(Devise)
4
+ before_action { EffectiveResources.authorize!(self, :admin, :effective_events) }
5
+
6
+ include Effective::CrudController
7
+
8
+ resource_scope -> { EffectiveEvents.EventRegistration.deep.all }
9
+ datatable -> { Admin::EffectiveEventRegistrationsDatatable.new }
10
+
11
+ private
12
+
13
+ def permitted_params
14
+ model = (params.key?(:effective_event_registration) ? :effective_event_registration : :event_registration)
15
+ params.require(model).permit!
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,8 @@
1
+ module Admin
2
+ class EventTicketsController < ApplicationController
3
+ before_action(:authenticate_user!) if defined?(Devise)
4
+ before_action { EffectiveResources.authorize!(self, :admin, :effective_events) }
5
+
6
+ include Effective::CrudController
7
+ end
8
+ end
@@ -0,0 +1,18 @@
1
+ module Admin
2
+ class EventsController < ApplicationController
3
+ before_action(:authenticate_user!) if defined?(Devise)
4
+ before_action { EffectiveResources.authorize!(self, :admin, :effective_events) }
5
+
6
+ include Effective::CrudController
7
+
8
+ submit :save, 'Save'
9
+ submit :save, 'Save and Add New', redirect: :new
10
+ submit :save, 'Save and View', redirect: -> { effective_events.event_path(resource) }
11
+ submit :save, 'Duplicate', redirect: -> { effective_events.new_admin_event_path(duplicate_id: resource.id) }
12
+
13
+ def permitted_params
14
+ params.require(:effective_event).permit!
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,53 @@
1
+ module Effective
2
+ class EventRegistrationsController < ApplicationController
3
+ before_action(:authenticate_user!) if defined?(Devise)
4
+
5
+ include Effective::WizardController
6
+
7
+ resource_scope -> {
8
+ event = Effective::Event.find(params[:event_id])
9
+ EffectiveEvents.EventRegistration.deep.where(owner: current_owner, event: event)
10
+ }
11
+
12
+ # Allow only 1 in-progress event registration at a time
13
+ before_action(only: [:new, :show], unless: -> { resource&.done? }) do
14
+ existing = resource_scope.in_progress.where.not(id: resource).first
15
+
16
+ if existing.present?
17
+ flash[:success] = "You have been redirected to your existing in progress event registration"
18
+ redirect_to effective_events.event_event_registration_build_path(existing.event, existing, existing.next_step)
19
+ end
20
+ end
21
+
22
+ after_save do
23
+ flash.now[:success] = ''
24
+ end
25
+
26
+ # The default redirect doesn't respect nested resources here
27
+ def new
28
+ self.resource ||= (find_wizard_resource || resource_scope.new)
29
+ EffectiveResources.authorize!(self, :new, resource)
30
+
31
+ redirect_to effective_events.event_event_registration_build_path(
32
+ resource.event,
33
+ (resource.to_param || :new),
34
+ (resource.first_uncompleted_step || resource_wizard_steps.first)
35
+ )
36
+ end
37
+
38
+ private
39
+
40
+ def current_owner
41
+ (current_user.class.respond_to?(:effective_memberships_owner?) ? current_user.effective_memberships_owners : current_user)
42
+ end
43
+
44
+ def permitted_params
45
+ model = (params.key?(:effective_event_registration) ? :effective_event_registration : :event_registration)
46
+
47
+ params.require(model).permit!.except(
48
+ :status, :status_steps, :wizard_steps, :submitted_at
49
+ )
50
+ end
51
+
52
+ end
53
+ end
@@ -0,0 +1,47 @@
1
+ module Effective
2
+ class EventsController < ApplicationController
3
+ include Effective::CrudController
4
+
5
+ resource_scope -> {
6
+ unpublished = EffectiveResources.authorized?(self, :admin, :effective_events)
7
+ Effective::Event.events(user: current_user, unpublished: unpublished)
8
+ }
9
+
10
+ def index
11
+ @events ||= resource_scope
12
+
13
+ @events = @events.paginate(page: params[:page])
14
+
15
+ # if params[:search].present?
16
+ # search = params[:search].permit(EffectiveEvents.permitted_params).delete_if { |k, v| v.blank? }
17
+ # @events = @events.where(search) if search.present?
18
+ # end
19
+
20
+ EffectiveResources.authorize!(self, :index, Effective::Event)
21
+
22
+ @page_title ||= ['Events', (" - Page #{params[:page]}" if params[:page])].compact.join
23
+ end
24
+
25
+ def show
26
+ @event = resource_scope.find(params[:id])
27
+
28
+ if @event.respond_to?(:roles_permit?)
29
+ raise Effective::AccessDenied.new('Access Denied', :show, @event) unless @event.roles_permit?(current_user)
30
+ end
31
+
32
+ EffectiveResources.authorize!(self, :show, @event)
33
+
34
+ if EffectiveResources.authorized?(self, :admin, :effective_events)
35
+ flash.now[:warning] = [
36
+ 'Hi Admin!',
37
+ ('You are viewing a hidden event.' if @event.draft?),
38
+ 'Click here to',
39
+ ("<a href='#{effective_events.edit_admin_event_path(@event)}' class='alert-link'>edit event settings</a>.")
40
+ ].compact.join(' ')
41
+ end
42
+
43
+ @page_title ||= @event.to_s
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,47 @@
1
+ module Admin
2
+ class EffectiveEventRegistrantsDatatable < Effective::Datatable
3
+ datatable do
4
+ col :updated_at, visible: false
5
+ col :created_at, visible: false
6
+ col :id, visible: false
7
+
8
+ col :event
9
+
10
+ col :owner, visible: false
11
+ col :event_registration, visible: false
12
+
13
+ if attributes[:event_id]
14
+ col :event_ticket, search: Effective::EventTicket.where(event: event).all
15
+ else
16
+ col :event_ticket, search: :string
17
+ end
18
+
19
+ col :purchased_order
20
+
21
+ col :first_name
22
+ col :last_name
23
+ col :email
24
+ col :company
25
+ col :number
26
+ col :notes, label: 'Restrictions and notes'
27
+
28
+ actions_col
29
+ end
30
+
31
+ collection do
32
+ scope = Effective::EventRegistrant.deep.purchased
33
+
34
+ if attributes[:event_id].present?
35
+ scope = scope.where(event: event)
36
+ end
37
+
38
+ scope
39
+ end
40
+
41
+ def event
42
+ @event ||= if attributes[:event_id]
43
+ Effective::Event.find(attributes[:event_id])
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,25 @@
1
+ class Admin::EffectiveEventRegistrationsDatatable < Effective::Datatable
2
+ datatable do
3
+ order :created_at
4
+
5
+ col :token, visible: false
6
+
7
+ col :created_at, label: 'Created', visible: false
8
+ col :updated_at, label: 'Updated', visible: false
9
+
10
+ col :submitted_at, label: 'Submitted', visible: false, as: :date
11
+
12
+ col :event
13
+ col :owner
14
+
15
+ col :event_registrants, search: :string
16
+ col :orders, label: 'Order'
17
+
18
+ actions_col
19
+ end
20
+
21
+ collection do
22
+ EffectiveEvents.EventRegistration.all.deep.done
23
+ end
24
+
25
+ end
@@ -0,0 +1,42 @@
1
+ module Admin
2
+ class EffectiveEventTicketsDatatable < Effective::Datatable
3
+ datatable do
4
+ reorder :position
5
+
6
+ col :updated_at, visible: false
7
+ col :created_at, visible: false
8
+ col :id, visible: false
9
+
10
+ col :event
11
+
12
+ col :title
13
+ col :regular_price, as: :price
14
+ col :early_bird_price, as: :price
15
+
16
+ col :capacity
17
+ col :purchased_event_registrants_count, label: 'Registered'
18
+
19
+ col :purchased_event_registrants, label: 'Registrants' do |ticket|
20
+ ticket.purchased_event_registrants.sort_by(&:last_name).map do |registrant|
21
+ content_tag(:div, registrant.last_first_name, class: 'col-resource_item')
22
+ end.join.html_safe
23
+ end
24
+
25
+ actions_col
26
+ end
27
+
28
+ collection do
29
+ scope = Effective::EventTicket.deep.all
30
+
31
+ if attributes[:event_id]
32
+ scope = scope.where(event: event)
33
+ end
34
+
35
+ scope
36
+ end
37
+
38
+ def event
39
+ Effective::Event.find(attributes[:event_id])
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,51 @@
1
+ module Admin
2
+ class EffectiveEventsDatatable < Effective::Datatable
3
+ filters do
4
+ scope :all
5
+ scope :registerable
6
+ scope :drafts
7
+ scope :upcoming
8
+ scope :past
9
+ end
10
+
11
+ datatable do
12
+ col :updated_at, visible: false
13
+ col :created_at, visible: false
14
+ col :id, visible: false
15
+
16
+ col :title
17
+ col :draft
18
+ col :start_at, label: 'Event Date'
19
+
20
+ col :end_at, visible: false
21
+ col :excerpt, visible: false
22
+
23
+ col :registration_start_at, label: 'Registration opens'
24
+ col :registration_end_at, label: 'Registration closes'
25
+ col :early_bird_end_at, label: 'Early bird ends'
26
+
27
+ col :early_bird do |event|
28
+ if event.early_bird?
29
+ content_tag(:span, event.early_bird_status, class: 'badge badge-success')
30
+ else
31
+ event.early_bird_status
32
+ end
33
+ end
34
+
35
+ col :event_tickets, search: :string
36
+ col :event_registrants, search: :string
37
+
38
+ col :roles, visible: false
39
+ col :authenticate_user, visible: false
40
+
41
+ actions_col do |event|
42
+ dropdown_link_to('View Event', effective_events.event_path(event), target: '_blank')
43
+ end
44
+ end
45
+
46
+ collection do
47
+ Effective::Event.deep.all
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,50 @@
1
+ # Used on the Event Registrations registrants step
2
+
3
+ class EffectiveEventRegistrantsDatatable < Effective::Datatable
4
+ datatable do
5
+
6
+ col :event_ticket, search: :string
7
+
8
+ col :name do |er|
9
+ "#{er.first_name} #{er.last_name}<br><small>#{mail_to(er.email)}</small>"
10
+ end
11
+
12
+ col :first_name, visible: false
13
+ col :last_name, visible: false
14
+ col :email, visible: false
15
+ col :company, visible: false
16
+ col :number, visible: false
17
+
18
+ col :price, as: :price
19
+ col :notes
20
+
21
+ # no actions_col
22
+ end
23
+
24
+ collection do
25
+ scope = Effective::EventRegistrant.deep.all
26
+
27
+ if event.present?
28
+ scope = scope.where(event: event)
29
+ end
30
+
31
+ if event_registration.present?
32
+ scope = scope.where(event_registration_id: event_registration)
33
+ end
34
+
35
+ scope
36
+ end
37
+
38
+ def event
39
+ @event ||= if attributes[:event_id]
40
+ Effective::Event.find(attributes[:event_id])
41
+ end
42
+ end
43
+
44
+ def event_registration
45
+ @event_registration ||= if attributes[:event_registration_id]
46
+ EffectiveEvents.EventRegistration.find_by_id(attributes[:event_registration_id])
47
+ end
48
+ end
49
+
50
+ end
@@ -0,0 +1,35 @@
1
+ # Dashboard Event Registrations
2
+ class EffectiveEventRegistrationsDatatable < Effective::Datatable
3
+ datatable do
4
+ order :created_at
5
+
6
+ col :token, visible: false
7
+ col :created_at, visible: false
8
+
9
+ col(:submitted_at, label: 'Registered on') do |er|
10
+ er.submitted_at&.strftime('%F') || 'Incomplete'
11
+ end
12
+
13
+ col :event, search: :string
14
+ col :owner, visible: false, search: :string
15
+ col :status, visible: false
16
+ col :event_registrants, search: :string
17
+ col :orders, action: :show, visible: false, search: :string
18
+
19
+ actions_col(actions: []) do |er|
20
+ if er.draft?
21
+ dropdown_link_to('Continue', effective_events.event_event_registration_build_path(er.event, er, er.next_step), 'data-turbolinks' => false)
22
+ dropdown_link_to('Delete', effective_events.event_event_registration_path(er.event, er), 'data-confirm': "Really delete #{er}?", 'data-method': :delete)
23
+ else
24
+ dropdown_link_to('Show', effective_events.event_event_registration_path(er.event, er))
25
+ end
26
+ end
27
+ end
28
+
29
+ collection do
30
+ owner = (current_user.respond_to?(:effective_memberships_owners) ? current_user.effective_memberships_owners : current_user)
31
+
32
+ EffectiveEvents.EventRegistration.deep.where(owner: owner)
33
+ end
34
+
35
+ end
@@ -0,0 +1,42 @@
1
+ # Dashboard Events
2
+ class EffectiveEventsDatatable < Effective::Datatable
3
+ filters do
4
+ # Upcoming should be first here, so when displayed as a simple datatable on the dashboard they only see upcoming events
5
+ scope :registerable
6
+ scope :all
7
+ end
8
+
9
+ datatable do
10
+ order :title
11
+ col :id, visible: false
12
+
13
+ col :start_at, label: 'Event Date'
14
+ col :title, label: 'Event', action: :show
15
+ col :excerpt, label: 'Details'
16
+
17
+ col :registration_start_at, visible: false
18
+ col :registration_end_at, label: 'Registration ends'
19
+
20
+ col :early_bird do |event|
21
+ if event.early_bird?
22
+ content_tag(:span, event.early_bird_status, class: 'badge badge-success')
23
+ else
24
+ event.early_bird_status
25
+ end
26
+ end
27
+
28
+ col :event_tickets, visible: false, search: :string
29
+ col :early_bird_end_at, label: 'Early bird ends', visible: false
30
+
31
+ actions_col do |event|
32
+ if event.registerable?
33
+ dropdown_link_to('Register', effective_events.new_event_event_registration_path(event))
34
+ end
35
+ end
36
+ end
37
+
38
+ collection do
39
+ Effective::Event.deep.events(user: current_user)
40
+ end
41
+
42
+ end
@@ -0,0 +1,18 @@
1
+ module EffectiveEventsHelper
2
+
3
+ def effective_events_event_tickets_collection(event)
4
+ raise('expected an Effective::Event') unless event.kind_of?(Effective::Event)
5
+
6
+ event.event_tickets.map do |ticket|
7
+ label = ticket.to_s
8
+ price = (ticket.price == 0 ? '$0' : number_to_currency(ticket.price))
9
+
10
+ ["#{label} - #{price}", ticket.to_param]
11
+ end
12
+ end
13
+
14
+ def edit_effective_event_registrations_wizard?
15
+ params[:controller] == 'effective/event_registrations' && defined?(resource) && resource.draft?
16
+ end
17
+
18
+ end