supplier improvements

This commit is contained in:
2013-03-09 14:18:21 +01:00
parent 730f910881
commit cc13797f5a
53 changed files with 819 additions and 156 deletions
@@ -4,7 +4,7 @@ module Suppliers
# GET /products
# GET /products.json
def index
@products = ProductDecorator.decorate_collection(current_supplier.products)
@products = current_supplier.products
respond_to do |format|
format.html # index.html.erb
@@ -15,7 +15,7 @@ module Suppliers
# GET /products/1
# GET /products/1.json
def show
@product = ProductDecorator.decorate(Product.find_by_supplier_id_and_id!(current_supplier.id, params[:id]))
@product = Product.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
respond_to do |format|
format.html # show.html.erb
@@ -84,5 +84,12 @@ module Suppliers
format.json { head :no_content }
end
end
def preview_products
@date = Date.parse(params[:date]) rescue Date.today
product_categories = ProductCategory.for_supplier_in_time(current_supplier, @date.to_time)
render json: {categories: product_categories.map(&:to_client_format).select(&:present?)}
end
end
end