Base progress

This commit is contained in:
2015-09-16 11:50:55 +02:00
parent ef894f9e02
commit 6a085b1ca2
52 changed files with 3686 additions and 1818 deletions
+8 -7
View File
@@ -10,13 +10,11 @@ module Users
table = Table.find(params[:id])
supplier = table.supplier
supplier.product_categories.include_relations(products: :product_variants)
render json: JSONAPI::Serializer.serialize(supplier, serializer: Users::SupplierSerializer, include: %w[
render json: supplier, include: %w[
product_categories
product_categories.products
product_categories.supplier
product_categories.products.product_variants
product_categories.products.product_variants.product
])
]
end
# POST /tables/:id/needs_help.json
@@ -25,7 +23,7 @@ module Users
render json: json_alert('messages.no_active_list', list_active: false) and return unless active_list.present?
active_list.needs_help!
#render json: JSONAPI::Serializer.serialize(@table, serializer: Users::TableSerializer)
render json: {}
head :no_content
end
# POST /user/tables/:id/join
@@ -35,7 +33,7 @@ module Users
if @list = @table.active_list
@list.send_table_join_request_for_user! current_user
end
head :ok
head :no_content
end
# GET /user/table_info.json
@@ -61,15 +59,18 @@ module Users
end
# Used by the user Ember app
# NOTE: ordering on a table always creates a new list or failes if the conditions for creating a new
# list are not met. To order on an already open list send the request to the lists controller
# POST /user/tables/:id/order_products
def order_products
table = Table.find(params[:id])
res = {}
res[:active_list_present] = true if active_list.present?
res[:occupied] = table.occupied?
res[:reserved] = table.reserved?
res[:supplier_closed] = table.supplier.closed?
res[:no_product_orders] = true unless product_orders = new_order_product_orders.presence
unless res[:occupied] or res[:supplier_closed] or res[:no_product_orders]
unless res[:occupied] or res[:supplier_closed] or res[:no_product_orders] or res[:active_list_present]
# Create new list
list = List.from_table( table, current_user )
res[:active_list_id] = list.id # used to set the active list in the app