68 lines
1.6 KiB
Ruby
68 lines
1.6 KiB
Ruby
module Suppliers
|
|
class SuppliersController < Suppliers::ApplicationController
|
|
def index
|
|
|
|
end
|
|
|
|
def show
|
|
[current_supplier].include_relations(sections: :tables, product_categories: {products: :product_variants})
|
|
render json: current_supplier, serializer: Suppliers::SupplierSerializer #.new(current_supplier).as_json
|
|
end
|
|
|
|
def update
|
|
@supplier = current_supplier
|
|
current_supplier.update_attributes(supplier_params)
|
|
render json: Suppliers::SupplierSerializer.new(current_supplier).as_json
|
|
end
|
|
|
|
def switch_to
|
|
@switch_supplier = Supplier.find(params[:id])
|
|
session[:supplier_id] = params[:id] if @switch_supplier.employee_ids.include? current_employee.id
|
|
redirect_to supplier_root_path(anchor: '/my-account')
|
|
end
|
|
|
|
def mark_as_open
|
|
current_supplier.mark_as_open!
|
|
head :ok
|
|
end
|
|
|
|
def mark_as_closed
|
|
current_supplier.mark_as_closed!
|
|
head :ok
|
|
end
|
|
def remove_needs_payment
|
|
@list = List.find_by_supplier_id_and_id(current_supplier.id, params[:id])
|
|
@list.remove_needs_payment!
|
|
head :ok
|
|
end
|
|
|
|
|
|
private
|
|
|
|
def supplier_params
|
|
params.require(:supplier).permit(
|
|
:name,
|
|
:email,
|
|
:open,
|
|
:time_zone,
|
|
:night_offset,
|
|
:location,
|
|
:lat,
|
|
:lng,
|
|
:offer_wifi,
|
|
:wifi_ssid,
|
|
:wifi_type,
|
|
:wifi_password,
|
|
:iens_profile,
|
|
:address,
|
|
:house_number,
|
|
:house_number_addition,
|
|
:postal_code,
|
|
:city,
|
|
:country,
|
|
:facebook_promotion_url
|
|
)
|
|
end
|
|
end
|
|
end
|