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]]
result = SpreeCmCommissioner::CheckIns::CreateBulk.call(
check_ins_attributes: guest_ids.map { |guest_id| { guest_id: guest_id, check_in_session_id: params[:check_in_session_id] } },
check_in_by: spree_current_user
)
if result.success?
flash[:success] = Spree.t('event.check_in.success')
else
flash[:error] = result.error.to_s
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
47
48
49
|
# File 'app/controllers/spree/events/guests_controller.rb', line 47
def edit
@check_in = @guest.earliest_check_in
end
|
#edit_object_url ⇒ Object
51
52
53
|
# File 'app/controllers/spree/events/guests_controller.rb', line 51
def edit_object_url
edit_event_guest_url
end
|
#generate_guest_bib_number ⇒ Object
64
65
66
67
68
69
|
# File 'app/controllers/spree/events/guests_controller.rb', line 64
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'app/controllers/spree/events/guests_controller.rb', line 85
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
55
56
57
58
59
60
61
62
|
# File 'app/controllers/spree/events/guests_controller.rb', line 55
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
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'app/controllers/spree/events/guests_controller.rb', line 71
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
|
# File 'app/controllers/spree/events/guests_controller.rb', line 32
def uncheck_in
result = SpreeCmCommissioner::CheckIns::DestroyBulk.call(
check_ins_attributes: [{ guest_id: params[:id], check_in_session_id: params[:check_in_session_id] }],
destroyed_by: spree_current_user
)
if result.success?
flash[:success] = Spree.t('event.uncheck_in.success')
else
flash[:error] = result.error.to_s
end
redirect_to edit_object_url
end
|