end of day commit

This commit is contained in:
2013-01-10 01:00:59 +01:00
parent b85bbf1aee
commit 87046c872c
23 changed files with 642 additions and 28 deletions
+25 -4
View File
@@ -22,7 +22,7 @@ module Suppliers
# GET /lists/1
# GET /lists/1.json
def show
@list = List.find_by_supplier_id_and_id(current_supplier.id, params[:id])
@list = List.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
respond_to do |format|
format.html {}
format.json do
@@ -36,6 +36,7 @@ module Suppliers
def new
@list = List.new
@list.section_id = params[:section_id].presence
@tables = current_supplier.active_tables
respond_to do |format|
format.html # new.html.erb
@@ -43,16 +44,36 @@ module Suppliers
end
end
# POST /lists
# POST /lists.json
def create
@list = List.new(params[:list])
@list.supplier = current_supplier
respond_to do |format|
if @list.save
format.html { redirect_to [:suppliers, @list.section || @list], notice: t('action.create.successfull', model: List.model_name.human) }
format.json { render json: @list, status: :created, location: @list }
else
format.html do
@tables = current_supplier.active_tables
render action: "new"
end
format.json { render json: @list.errors, status: :unprocessable_entity }
end
end
end
# GET /lists/1/edit
def edit
@list = List.find_by_supplier_id_and_id(current_supplier.id, params[:id])
@list = List.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
@tables = current_supplier.active_tables
end
# PUT /lists/1
# PUT /lists/1.json
def update
@list = List.find_by_supplier_id_and_id(current_supplier.id, params[:id])
@list = List.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
respond_to do |format|
if @list.update_attributes(params[:list])
@@ -71,7 +92,7 @@ module Suppliers
# DELETE /lists/1
# DELETE /lists/1.json
def destroy
@list = List.find_by_supplier_id_and_id(current_supplier.id, params[:id])
@list = List.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
@list.destroy
respond_to do |format|
@@ -15,7 +15,7 @@ module Suppliers
# GET /products/1
# GET /products/1.json
def show
@product = ProductDecorator.find(params[:id])
@product = ProductDecorator.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
respond_to do |format|
format.html # show.html.erb
@@ -27,6 +27,7 @@ module Suppliers
# GET /products/new.json
def new
@product = Product.new
@product.add_product_category ProductCategory.find_by_supplier_id_and_id!(current_supplier.id, params[:product_category_id]) if params[:product_category_id].present?
respond_to do |format|
format.html # new.html.erb
@@ -59,7 +60,7 @@ module Suppliers
# PUT /products/1
# PUT /products/1.json
def update
@product = Product.find(params[:id])
@product = Product.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
respond_to do |format|
if @product.update_attributes(params[:product])
@@ -75,7 +76,7 @@ module Suppliers
# DELETE /products/1
# DELETE /products/1.json
def destroy
@product = Product.find(params[:id])
@product = Product.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
@product.destroy
respond_to do |format|
@@ -14,7 +14,7 @@ module Suppliers
# GET /tables/1
# GET /tables/1.json
def show
@table = Table.find(params[:id])
@table= Table.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
respond_to do |format|
format.html # show.html.erb
@@ -59,7 +59,7 @@ module Suppliers
# PUT /tables/1
# PUT /tables/1.json
def update
@table = Table.find(params[:id])
@table= Table.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
respond_to do |format|
if @table.update_attributes(params[:table])
@@ -77,7 +77,7 @@ module Suppliers
# DELETE /tables/1
# DELETE /tables/1.json
def destroy
@table = Table.find(params[:id])
@table= Table.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
@table.destroy
respond_to do |format|