Class: Spree::Events::GuestsController
Instance Method Summary
collapse
#current_event, #default_url_options, #events, #required_user_event!
#authorize?, #authorize_admin, #authorize_role!, #redirect_unauthorized_access, #resource_not_found
Instance Method Details
#check_in ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'app/controllers/spree/events/guests_controller.rb', line 16
def check_in
guest_ids = [params[:id]]
context = SpreeCmCommissioner::CheckInBulkCreator.call(
check_ins_attributes: guest_ids.map { |guest_id| { guest_id: guest_id } },
check_in_by: spree_current_user
)
if context.success?
flash[:success] = Spree.t('event.check_in.success')
else
flash[:error] = context.message.to_s.titleize
end
redirect_to edit_object_url
end
|
#collection_url ⇒ Object
8
9
10
|
# File 'app/controllers/spree/events/guests_controller.rb', line 8
def collection_url
event_guests_url
end
|
#edit ⇒ Object
48
49
50
|
# File 'app/controllers/spree/events/guests_controller.rb', line 48
def edit
@check_in = @guest.check_in
end
|
#edit_object_url ⇒ Object
52
53
54
|
# File 'app/controllers/spree/events/guests_controller.rb', line 52
def edit_object_url
edit_event_guest_url
end
|
#generate_guest_bib_number ⇒ Object
65
66
67
68
69
70
|
# File 'app/controllers/spree/events/guests_controller.rb', line 65
def generate_guest_bib_number
@guest.generate_bib!
flash[:success] = 'Bib number generated successfully' redirect_to event_guest_path
end
|
#generate_guest_csv ⇒ Object
POST: /guests/generate_guest_csv
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'app/controllers/spree/events/guests_controller.rb', line 86
def generate_guest_csv
name = "guest-csv#{Time.current.to_i}"
file_name = "guests-data-#{current_event.name.gsub(' ', '-')}-#{Time.current.to_i}.csv"
file_path = Rails.root.join('tmp', file_name)
export_type = SpreeCmCommissioner::Exports::ExportGuestCsv
guest_csv = SpreeCmCommissioner::Exports::ExportGuestCsv.new(
name: name,
file_name: file_name,
file_path: file_path,
export_type: export_type,
preferred_event_id: current_event.id
)
if guest_csv.save
flash[:success] = Spree.t('csv.csv_generate')
redirect_to event_data_exports_path
else
flash[:error] = Spree.t('csv.generate_error')
redirect_back(fallback_location: event_guests_path)
end
end
|
#model_class ⇒ Object
12
13
14
|
# File 'app/controllers/spree/events/guests_controller.rb', line 12
def model_class
SpreeCmCommissioner::Guest
end
|
#send_email ⇒ Object
56
57
58
59
60
61
62
63
|
# File 'app/controllers/spree/events/guests_controller.rb', line 56
def send_email
@email = params[:guest][:email]
Spree::OrderMailer.ticket_email(@guest, @email).deliver_later
flash[:success] = 'Email sent successfully' redirect_to event_guest_path
end
|
#swap_guest_bib_number ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'app/controllers/spree/events/guests_controller.rb', line 72
def swap_guest_bib_number
target_guest = @filtered_guests.find(params[:target_guest_id])
SpreeCmCommissioner::BibNumberSwapper.call(
guests: @filtered_guests,
current_guest: @guest,
target_guest: target_guest
)
flash[:success] = 'Bib number swapped successfully' redirect_to event_guests_path
end
|
#uncheck_in ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'app/controllers/spree/events/guests_controller.rb', line 32
def uncheck_in
guest_ids = [params[:id]]
context = SpreeCmCommissioner::CheckInDestroyer.call(
guest_ids: guest_ids,
destroyed_by: spree_current_user
)
if context.success?
flash[:success] = Spree.t('event.uncheck_in.success')
else
flash[:error] = context.message.to_s.titleize
end
redirect_to edit_object_url
end
|