backup push

This commit is contained in:
2012-08-24 16:20:03 +02:00
parent e3c189d187
commit 4765608e2d
17 changed files with 172 additions and 56 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ class ApplicationController < ActionController::Base
if session[:active_list_id]
unless active_list.active?
session[:active_list_id] = nil
redirect_to root_path, alert: t('messages.the_list_has_been_closed')
redirect_to phone_root_path, alert: t('messages.the_list_has_been_closed', list: List.model_name.human)
end
end
+15 -2
View File
@@ -5,6 +5,7 @@ class DashboardController < ApplicationController
end
def phone_home
flash.now[:notice] = t('messages.the_list_has_been_closed', list: List.model_name.human) if params[:list_closed].present?
render layout: 'phone'
end
@@ -32,7 +33,7 @@ class DashboardController < ApplicationController
render layout: 'phone'
end
def order_active_list
def order_active_products_list
respond_to do |format|
format.html do
redirect_to(root_path, alert: t('messages.cannot_order_without_list_id')) and return if params[:list_id].blank?
@@ -62,7 +63,7 @@ class DashboardController < ApplicationController
render layout: 'phone'
end
def list_info
def user_list_info
respond_to do |format|
format.json do
render json: {list_active: false} and return unless session[:active_list_id].present?
@@ -78,4 +79,16 @@ class DashboardController < ApplicationController
def supplier_lists
redirect_to active_lists_supplier_path(Supplier.first)
end
# POST /active_user_list_needs_help
def active_user_list_needs_help
respond_to do |format|
format.json do
render json: {list_active: false} and return unless session[:active_list_id].present?
active_list.needs_help = true
active_list.save
render json: active_list.as_json.merge(list_active: true)
end
end
end
end
+11 -3
View File
@@ -94,8 +94,8 @@ class ListsController < ApplicationController
ho = {products: []}
order_total = 0.0
for product_order in order.product_orders
order_total += (product_order.amount * product_order.product.price).round(2)
ho[:products] << {name: product_order.product.name, id: product_order.product_id, number: product_order.amount, price: product_order.product.price}
order_total += (product_order.amount * product_order.price).round(2)
ho[:products] << {name: product_order.product.name, id: product_order.product_id, number: product_order.amount, price: product_order.price}
end
ho[:total_amount] = order_total.round(2)
ho[:state] = order.state
@@ -110,12 +110,20 @@ class ListsController < ApplicationController
end
# POST /orders/1/is_delivered
# POST /orders/1/is_closed
def is_closed
@list = List.find(params[:id])
@list.close!
render nothing: true
end
# POST /orders/1/is_helped
def is_helped
@list = List.find(params[:id])
@list.needs_help = false
@list.save
render nothing: true
end
private
def set_relation_options
+4 -3
View File
@@ -113,8 +113,8 @@ class SuppliersController < ApplicationController
ho = {products: []}
order_total = 0.0
for product_order in order.product_orders
order_total += (product_order.amount * product_order.product.price).round(2)
ho[:products] << {name: product_order.product.name, id: product_order.product_id, number: product_order.amount, price: product_order.product.price}
order_total += (product_order.amount * product_order.price).round(2)
ho[:products] << {name: product_order.product.name, id: product_order.product_id, number: product_order.amount, price: product_order.price}
end
ho[:total_amount] = order_total.round(2)
ho[:state] = order.state
@@ -141,7 +141,7 @@ class SuppliersController < ApplicationController
grand_total = 0.0
for list in @supplier.active_lists
hl = list.as_json
hl[:total_amount] = list.orders.inject(0.0){|sum, o| sum + o.product_orders.inject(0.0){|s, po| s + (po.amount * po.product.price).round(2)}}.round(2)
hl[:total_amount] = list.orders.inject(0.0){|sum, o| sum + o.product_orders.inject(0.0){|s, po| s + (po.amount * po.price).round(2)}}.round(2)
grand_total += hl[:total_amount]
h[:lists] << hl
end
@@ -150,6 +150,7 @@ class SuppliersController < ApplicationController
end
end
end
private
def set_relation_options