Conceptual architectural change for CLI user app
This commit is contained in:
@@ -29,54 +29,6 @@ class UserController < Users::ApplicationController
|
||||
#end
|
||||
#end
|
||||
|
||||
# GET /user/table_info.json
|
||||
# used for moving table request
|
||||
# TODO wrap logic of actions
|
||||
# - table_info
|
||||
# - move_table
|
||||
# into separate class and implement security in a non stupid way as it is now
|
||||
def table_info
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
render json: json_alert('messages.table_not_found') and return unless params[:table_id].present?
|
||||
@table = Table.find(params[:table_id])
|
||||
res = {}
|
||||
res[:occupied] = @table.occupied?
|
||||
res[:reserved] = @table.reserved?
|
||||
res[:supplier_closed] = @table.supplier.closed?
|
||||
res[:table] = @table.attributes
|
||||
if list.present?
|
||||
res[:other_supplier] = true if list.supplier_id != @table.supplier_id
|
||||
res[:current_table_id] = list.table_id
|
||||
end
|
||||
render json: res
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# POST /user/move_table.json
|
||||
# used to move the table
|
||||
# TODO wrap logic of actions
|
||||
# - table_info
|
||||
# - move_table
|
||||
# into separate class and implement security in a non stupid way as it is now
|
||||
def move_table
|
||||
render json: json_alert('messages.no_active_list', list_active: false) and return unless list.present?
|
||||
render json: json_alert('messages.table_not_found') and return unless params[:table_id].present?
|
||||
@table = Table.find(params[:table_id])
|
||||
if @table.occupied?
|
||||
render json: {occupied: true}
|
||||
elsif @table.reserved?
|
||||
render json: {reserved: true}
|
||||
elsif list.supplier_id != @table.supplier_id
|
||||
res[:other_supplier] = true if list.supplier_id != @table.supplier_id
|
||||
res[:current_table_id] = list.table_id
|
||||
else
|
||||
list.move_to_table! @table
|
||||
render json: {occupied: false, reserved: false}
|
||||
end
|
||||
end
|
||||
|
||||
# GET /suppliers/1/product_list
|
||||
# GET /suppliers/1/product_list.json
|
||||
def list_products
|
||||
@@ -119,16 +71,6 @@ class UserController < Users::ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
# POST /user/join_occupied_table
|
||||
def request_to_join_occupied_table
|
||||
render json: json_alert('messages.table_not_found') and return unless params[:table_id].present?
|
||||
@table = Table.find(params[:table_id])
|
||||
if @list = @table.active_list
|
||||
@list.send_table_join_request_for_user! current_user
|
||||
end
|
||||
render nothing: true
|
||||
end
|
||||
|
||||
# POST /user/reject_join_request?user_id=1
|
||||
def reject_join_request
|
||||
render js: '' and return unless params[:user_id].present?
|
||||
@@ -203,28 +145,6 @@ class UserController < Users::ApplicationController
|
||||
render json: {}
|
||||
end
|
||||
|
||||
# POST /user/needs_help.json
|
||||
def needs_help
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
render json: json_alert('messages.no_active_list', list_active: false) and return unless list.present?
|
||||
list.needs_help!
|
||||
render json: list.as_json.merge(list_active: list.active?)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# POST /user/list_needs_payment.json
|
||||
def list_needs_payment
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
render json: json_alert('messages.no_active_list', list_active: false) and return unless list.present?
|
||||
list.needs_payment!
|
||||
render json: list.as_json.merge(list_active: list.active?)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
##
|
||||
# Displays the closed lists of the user
|
||||
# GET /user/list_history
|
||||
|
||||
Reference in New Issue
Block a user