Poltergeist in the green, and resourceful refactor

This commit is contained in:
2015-02-27 15:12:08 +01:00
parent d1015dcc88
commit 046058b5d2
31 changed files with 210 additions and 165 deletions
@@ -0,0 +1,67 @@
module Suppliers
class SuppliersController < Suppliers::ApplicationController
def index
end
def show
[current_supplier].include_relations(sections: :tables, product_categories: :products)
render json: 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: '/settings')
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