end of day commit

This commit is contained in:
2012-08-23 18:50:06 +02:00
parent 13dd2bf335
commit 0bae1bcbed
37 changed files with 1157 additions and 83 deletions
+27 -2
View File
@@ -1,5 +1,6 @@
class DashboardController < ApplicationController
before_filter :check_active_list_state, except: :home
def home
end
@@ -17,8 +18,8 @@ class DashboardController < ApplicationController
@list = List.new(table: @table)
#@list.add_user(current_user)
@list.save
session[:list_id] = @list.id
redirect_to root_path
session[:active_list_id] = @list.id
redirect_to action: :show_products
end
end
@@ -27,4 +28,28 @@ class DashboardController < ApplicationController
end
def order_active_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?
@list = List.find(params[:list_id])
redirect_to(root_path, alert: t('messages.cannot_order_on_non_active_list')) and return unless @list.active?
@list.place_order params[:products]
redirect_to root_path, notice: t('messages.order_is_placed')
end
format.js do
render js: js_alert(t('messages.cannot_order_without_list_id')) and return if params[:list_id].blank?
@list = List.find(params[:list_id])
render js: js_alert(t('messages.cannot_order_on_non_active_list')) and return unless @list.active?
@list.place_order params[:products]
render js: js_notice( t('messages.order_is_placed') )
end
end
end
def view_active_list
redirect_to(root_path, alert: t('messages.there_is_no_list_active')) and return unless session[:active_list_id].present?
end
end