Basic functionality working
This commit is contained in:
@@ -25,7 +25,7 @@ module Users
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@list ||= List.find(params[:id])
|
@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: {}, 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])
|
render json: JSONAPI::Serializer.serialize(@list, serializer: Users::ListSerializer, include: %w[supplier users])
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,8 +9,14 @@ module Users
|
|||||||
def supplier
|
def supplier
|
||||||
table = Table.find(params[:id])
|
table = Table.find(params[:id])
|
||||||
supplier = table.supplier
|
supplier = table.supplier
|
||||||
supplier.product_categories.include_relations(:products)
|
supplier.product_categories.include_relations(products: :product_variants)
|
||||||
render json: JSONAPI::Serializer.serialize(supplier, serializer: Users::SupplierSerializer, include: %w[product_categories product_categories.products product_categories.supplier])
|
render json: JSONAPI::Serializer.serialize(supplier, serializer: Users::SupplierSerializer, include: %w[
|
||||||
|
product_categories
|
||||||
|
product_categories.products
|
||||||
|
product_categories.supplier
|
||||||
|
product_categories.products.product_variants
|
||||||
|
product_categories.products.product_variants.product
|
||||||
|
])
|
||||||
end
|
end
|
||||||
|
|
||||||
# POST /tables/:id/needs_help.json
|
# POST /tables/:id/needs_help.json
|
||||||
@@ -39,8 +45,8 @@ module Users
|
|||||||
# - move_table
|
# - move_table
|
||||||
# into separate class and implement security in a non stupid way as it is now
|
# into separate class and implement security in a non stupid way as it is now
|
||||||
def status_info
|
def status_info
|
||||||
render json: json_alert('messages.table_not_found') and return unless params[:table_id].present?
|
render json: json_alert('messages.table_not_found') and return unless params[:id].present?
|
||||||
table = Table.find(params[:table_id])
|
table = Table.find(params[:id])
|
||||||
res = {}
|
res = {}
|
||||||
res[:occupied] = table.occupied?
|
res[:occupied] = table.occupied?
|
||||||
res[:reserved] = table.reserved?
|
res[:reserved] = table.reserved?
|
||||||
|
|||||||
@@ -1,14 +1,18 @@
|
|||||||
class Users::ProductSerializer
|
class Users::ProductSerializer
|
||||||
include Qwaiter::UserBaseSerializer
|
include Qwaiter::UserBaseSerializer
|
||||||
attributes :name, :price, :description, :image, :code, :position, :visible, :active, :product_category_id
|
HOST = Rails.application.config.action_controller.asset_host.to_s
|
||||||
|
attributes :name, :price, :description, :code, :position, :visible, :active
|
||||||
|
attribute :image do
|
||||||
|
if object.image.present?
|
||||||
|
{
|
||||||
|
thumb: File.join(HOST, object.image.url(:thumb).to_s),
|
||||||
|
small: File.join(HOST, object.image.url(:small).to_s)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
dummy = File.join(HOST, object.image.url.to_s)
|
||||||
|
{thumb: dummy, small: dummy}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
has_many :product_variants, serializer: Users::ProductVariantSerializer
|
has_many :product_variants, serializer: Users::ProductVariantSerializer
|
||||||
|
|
||||||
def image
|
|
||||||
if object.image.present?
|
|
||||||
{small: object.image.url(:small)}
|
|
||||||
else
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
class Users::ProductVariantSerializer
|
class Users::ProductVariantSerializer
|
||||||
include Qwaiter::UserBaseSerializer
|
include Qwaiter::UserBaseSerializer
|
||||||
attributes :name
|
attributes :name
|
||||||
|
|
||||||
|
has_one :product, serializer: Users::ProductSerializer
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ Qwaiter::Application.configure do
|
|||||||
|
|
||||||
config.ember.variant = :development
|
config.ember.variant = :development
|
||||||
|
|
||||||
|
config.action_controller.asset_host = "http://localhost:3000"
|
||||||
# config.web_console.automount = true
|
# config.web_console.automount = true
|
||||||
|
|
||||||
# Don't care if the mailer can't send
|
# Don't care if the mailer can't send
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ Qwaiter::Application.configure do
|
|||||||
# config.cache_store = :mem_cache_store
|
# config.cache_store = :mem_cache_store
|
||||||
|
|
||||||
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
||||||
# config.action_controller.asset_host = "http://assets.example.com"
|
config.action_controller.asset_host = "http://assets.mozo.bar"
|
||||||
|
|
||||||
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
||||||
# config.assets.precompile += %w( search.js )
|
# config.assets.precompile += %w( search.js )
|
||||||
|
|||||||
Reference in New Issue
Block a user