Base progress
This commit is contained in:
@@ -8,12 +8,13 @@ module Users
|
||||
#lists.reject!{|l| l.id == params[:exclude_list]} if params[:exclude_list].present?
|
||||
#lists.reject!{|l| l.id == current_user.active_list_id } if current_user && current_user.active_list_id.present? # see spec Loading lists and switching to the order products view works, lists loading may unlink active list orders
|
||||
lists.include_relation(:users, :supplier)
|
||||
render json: JSONAPI::Serializer.serialize(lists, serializer: Users::ListSerializer, include: %w[supplier users], is_collection: true, meta: {total_pages: lists.total_pages, page: lists.current_page}) #, root: :lists
|
||||
render json: lists, include: %w[supplier users], meta: {total_pages: lists.total_pages, page: lists.current_page} #, root: :lists
|
||||
end
|
||||
|
||||
#EMBER
|
||||
def current
|
||||
@list = current_user.active_list
|
||||
params[:id] = @list.id # serializer determines collection or not based on the presence of this
|
||||
show
|
||||
end
|
||||
|
||||
@@ -21,13 +22,13 @@ module Users
|
||||
list = List.find(params[:id])
|
||||
render json: {}, status: :not_found and return unless list.present?
|
||||
@table = list.table
|
||||
render json: JSONAPI::Serializer.serialize(@table, serializer: Users::TableSerializer)
|
||||
render json: @table
|
||||
end
|
||||
|
||||
def show
|
||||
@list ||= List.find(params[:id]) if params[:id]
|
||||
render json: {}, status: :not_found and return unless @list.present? && Array.wrap(@list.user_ids).include?(current_user.id)
|
||||
render json: JSONAPI::Serializer.serialize(@list, serializer: Users::ListSerializer, include: %w[supplier users join_requests join_requests.user])
|
||||
render json: @list, include: %w[supplier users join_requests join_requests.user]
|
||||
end
|
||||
|
||||
# POST /user/list_needs_payment.json
|
||||
@@ -35,7 +36,7 @@ module Users
|
||||
@list = active_list
|
||||
render json: json_alert('messages.no_active_list', list_active: false) and return unless @list.try(:id).to_s == params[:id]
|
||||
@list.needs_payment!
|
||||
render json: JSONAPI::Serializer.serialize(@list, serializer: Users::ListSerializer)
|
||||
render json: @list
|
||||
end
|
||||
|
||||
# POST /user/lists/:id/move_table.json?table_id=....
|
||||
@@ -80,7 +81,7 @@ module Users
|
||||
def reject_join_request
|
||||
render js: '' and return unless params[:user_id].present?
|
||||
active_list && active_list.reject_join_request_for_user!(params[:user_id])
|
||||
head :ok
|
||||
head :no_content
|
||||
end
|
||||
|
||||
# POST /user/approve_join_request?user_id=1
|
||||
@@ -88,7 +89,7 @@ module Users
|
||||
render js: '' and return unless params[:user_id].present?
|
||||
@user = User.find(params[:user_id])
|
||||
active_list && active_list.approve_join_request_for_user!(@user)
|
||||
head :ok
|
||||
head :no_content
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user