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