event based table join system
This commit is contained in:
@@ -78,6 +78,7 @@ class UserController < ApplicationController
|
||||
# GET /suppliers/1/product_list
|
||||
# GET /suppliers/1/product_list.json
|
||||
def list_products
|
||||
redirect_to(user_root_path(message: 'the_list_has_been_closed')) and return unless list
|
||||
@supplier = list.supplier
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
@@ -113,44 +114,30 @@ class UserController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# GET /user/join_occupied_table
|
||||
def join_occupied_table
|
||||
redirect_to user_root_path(message: 'table_not_found') and return unless params[:table_id].present?
|
||||
@table = Table.find(params[:table_id])
|
||||
end
|
||||
|
||||
# POST /user/join_occupied_table
|
||||
def request_to_join_occupied_table
|
||||
@table = Table.find(params[:table_id])
|
||||
if @list = @table.active_list
|
||||
unless @list.join_requests.include?(current_user.id)
|
||||
@list.join_requests << current_user.id
|
||||
@list.is_dirty
|
||||
@list.save
|
||||
end
|
||||
|
||||
@list.send_table_join_request_for_user! current_user
|
||||
end
|
||||
render nothing: true
|
||||
end
|
||||
|
||||
def reject_join_request
|
||||
return unless params[:user_id]
|
||||
if list && list.join_requests.include?(params[:user_id])
|
||||
list.join_requests.delete(params[:user_id])
|
||||
list.is_dirty
|
||||
list.save
|
||||
end
|
||||
list && list.reject_join_request_for_user!(params[:user_id])
|
||||
render js: ''
|
||||
end
|
||||
def approve_join_request
|
||||
return unless params[:user_id]
|
||||
@user = User.find(params[:user_id])
|
||||
if list && list.join_requests.include?(params[:user_id])
|
||||
list.join_requests.delete(params[:user_id])
|
||||
@user.active_list_id = list.id
|
||||
list.add_user(@user)
|
||||
@user.save
|
||||
list.is_dirty
|
||||
list.save
|
||||
end
|
||||
list && list.approve_join_request_for_user!(@user)
|
||||
render nothing: true
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user