Class: Spree::Admin::GuestsController
- Inherits:
-
ResourceController
- Object
- ResourceController
- Spree::Admin::GuestsController
- Includes:
- OrderConcern
- Defined in:
- app/controllers/spree/admin/guests_controller.rb
Instance Method Summary collapse
- #add_guest ⇒ Object
- #check_in ⇒ Object
- #collection_url ⇒ Object
- #edit ⇒ Object
- #model_class ⇒ Object
- #new ⇒ Object
- #object_name ⇒ Object
- #remove_guest ⇒ Object
- #uncheck_in ⇒ Object
Instance Method Details
#add_guest ⇒ Object
22 23 24 25 26 |
# File 'app/controllers/spree/admin/guests_controller.rb', line 22 def add_guest SpreeCmCommissioner::Cart::AddGuest.call(order: @order, line_item: @order.line_items.find(params[:line_item_id])) redirect_to location_after_save end |
#check_in ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/controllers/spree/admin/guests_controller.rb', line 49 def check_in result = SpreeCmCommissioner::CheckInBulkCreator.call( check_ins_attributes: [{ guest_id: @guest.id }], check_in_by: spree_current_user ) if result.success? flash[:success] = "Guest #{@guest.full_name} has been checked in." else flash[:error] = result..to_s.titleize end redirect_to collection_url end |
#collection_url ⇒ Object
14 15 16 |
# File 'app/controllers/spree/admin/guests_controller.rb', line 14 def collection_url spree.admin_order_guests_url(@order) end |
#edit ⇒ Object
44 45 46 47 |
# File 'app/controllers/spree/admin/guests_controller.rb', line 44 def edit @kyc_fields = @object.line_item.kyc_fields @check_in = @object.check_in end |
#model_class ⇒ Object
10 11 12 |
# File 'app/controllers/spree/admin/guests_controller.rb', line 10 def model_class SpreeCmCommissioner::Guest end |
#new ⇒ Object
39 40 41 42 |
# File 'app/controllers/spree/admin/guests_controller.rb', line 39 def new @line_item = @order.line_items.find(params[:line_item_id]) @kyc_fields = @line_item.kyc_fields end |
#object_name ⇒ Object
18 19 20 |
# File 'app/controllers/spree/admin/guests_controller.rb', line 18 def object_name 'spree_cm_commissioner_guest' end |
#remove_guest ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/spree/admin/guests_controller.rb', line 28 def remove_guest @line_item = @order.line_items.find(params[:line_item_id]) SpreeCmCommissioner::Cart::RemoveGuest.call(order: @order, line_item: @line_item, guest_id: params[:guest_id]) respond_to do |format| format.html { redirect_to location_after_destroy } format.js { render js: 'window.location.reload(true);' } end end |
#uncheck_in ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'app/controllers/spree/admin/guests_controller.rb', line 64 def uncheck_in result = SpreeCmCommissioner::CheckInDestroyer.call( guest_ids: [@guest.id], destroyed_by: spree_current_user ) if result.success? flash[:success] = "Guest #{@guest.full_name} has been unchecked." else flash[:error] = result..to_s.titleize end redirect_to collection_url end |