end of day commit for users and suppliers authenticated handling
This commit is contained in:
@@ -15,92 +15,45 @@ class DashboardController < ApplicationController
|
||||
render layout: 'phone'
|
||||
end
|
||||
|
||||
def create_list
|
||||
@table = Table.find(params[:table_id])
|
||||
if @table.occupied?
|
||||
redirect_to root_path, alert: t('table.is_occupied')
|
||||
else
|
||||
@list = List.new(table: @table)
|
||||
#@list.add_user(current_user)
|
||||
@list.save
|
||||
session[:active_list_id] = @list.id
|
||||
redirect_to action: :show_products
|
||||
end
|
||||
end
|
||||
|
||||
def show_products
|
||||
@supplier = Supplier.first
|
||||
render layout: 'phone'
|
||||
end
|
||||
|
||||
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?
|
||||
@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]
|
||||
@list.place_order current_user, 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]
|
||||
@list.place_order current_user, 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?
|
||||
render layout: 'phone'
|
||||
end
|
||||
|
||||
##
|
||||
# Displays the closed lists of the user
|
||||
def user_history
|
||||
render layout: 'phone'
|
||||
end
|
||||
|
||||
def user_list_info
|
||||
# GET /suppliers/1/product_list
|
||||
# GET /suppliers/1/product_list.json
|
||||
def product_list
|
||||
@supplier = active_list.supplier
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json do
|
||||
render json: {list_active: false} and return unless session[:active_list_id].present?
|
||||
render json: active_list.as_json.merge(list_active: true)
|
||||
products = active_list.supplier.products
|
||||
products.include_relation(:product_categories)
|
||||
products.sort_by!{|p| p.product_category.try(:position) || 90000}
|
||||
h = products.inject({}){|h, p| n = p.product_category.try(:name) || 'other'; h[n] ||= []; h[n] << p; h}
|
||||
render json: h
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def supplier_home
|
||||
redirect_to active_orders_supplier_path(Supplier.first)
|
||||
end
|
||||
|
||||
def supplier_lists
|
||||
redirect_to active_lists_supplier_path(Supplier.first)
|
||||
end
|
||||
|
||||
# POST /active_user_list_needs_help.json
|
||||
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
|
||||
|
||||
# POST /active_user_list_needs_payment.json
|
||||
def active_user_list_needs_payment
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
render json: {list_active: false} and return unless session[:active_list_id].present?
|
||||
active_list.needs_payment = true
|
||||
active_list.save
|
||||
render json: active_list.as_json.merge(list_active: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user