basic user needs closing functionality infrastructure
This commit is contained in:
@@ -3,6 +3,7 @@ Qsupplier.App.List = DS.Model.extend
|
||||
state: attr 'string'
|
||||
needs_help: attr 'boolean'
|
||||
needs_payment: attr 'boolean'
|
||||
user_requests_closing: attr('boolean')
|
||||
is_paid: attr 'boolean'
|
||||
has_active_orders: attr 'boolean'
|
||||
price: attr 'number'
|
||||
|
||||
@@ -3,6 +3,7 @@ App.List = DS.Model.extend
|
||||
orders: DS.hasMany('order')
|
||||
needs_help: attr('boolean')
|
||||
needs_payment: attr('boolean')
|
||||
user_requests_closing: attr('boolean')
|
||||
supplier_name: attr('string')
|
||||
state: attr('string')
|
||||
price: attr('number')
|
||||
|
||||
@@ -3,6 +3,7 @@ App.List = DS.Model.extend
|
||||
state: attr 'string'
|
||||
needs_help: attr 'boolean'
|
||||
needs_payment: attr 'boolean'
|
||||
user_requests_closing: attr('boolean')
|
||||
is_paid: attr 'boolean'
|
||||
has_active_orders: attr 'boolean'
|
||||
price: attr 'number'
|
||||
|
||||
+25
-6
@@ -11,6 +11,7 @@ class List
|
||||
property :price, type: Float
|
||||
property :is_paid, type: :boolean, default: false
|
||||
property :paid_at, type: Time
|
||||
property :user_requests_closing, :boolean, default: false
|
||||
|
||||
has_many :orders, dependent: :destroy
|
||||
belongs_to :table
|
||||
@@ -185,6 +186,17 @@ class List
|
||||
end
|
||||
end
|
||||
|
||||
def user_requests_closing!
|
||||
return if user_requests_closing?
|
||||
self.user_requests_closing = true
|
||||
if save
|
||||
broadcast_users 'user_requests_closing', id: id
|
||||
broadcast_employees 'user_requests_closing', id: id
|
||||
broadcast_supplier supplier_id, 'user_requests_closing', id: id
|
||||
end
|
||||
#pending
|
||||
end
|
||||
|
||||
|
||||
def move_to_table! to_table
|
||||
UserTableMove.create list: self, from_table_id: table_id, to_table: to_table
|
||||
@@ -299,12 +311,6 @@ class List
|
||||
order
|
||||
end
|
||||
|
||||
def broadcast_users(message, content = {})
|
||||
for user_id in Array.wrap(user_ids)
|
||||
broadcast_user user_id, message, content
|
||||
end
|
||||
end
|
||||
|
||||
def as_json(*args)
|
||||
super.merge(id: id, table_number: table_number, has_active_orders: has_active_orders? )
|
||||
end
|
||||
@@ -398,4 +404,17 @@ class List
|
||||
hl[:section_title] = table.section.try(:title)
|
||||
@with_info_as_json = hl
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def broadcast_users(message, content = {})
|
||||
for user_id in Array.wrap(user_ids)
|
||||
broadcast_user user_id, message, content
|
||||
end
|
||||
end
|
||||
|
||||
def broadcast_employees(message, content = {})
|
||||
#PENDING
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class ListSerializer < Qwaiter::Serializer
|
||||
# user ids for facebook pictures
|
||||
#embed :ids
|
||||
attributes :state, :needs_help, :needs_payment, :is_paid, :price, :table_id, :table_number, :section_id, :user_ids, :supplier_id #, :has_active_orders
|
||||
attributes :state, :needs_help, :needs_payment, :user_requests_closing, :is_paid, :price, :table_id, :table_number, :section_id, :user_ids, :supplier_id #, :has_active_orders
|
||||
|
||||
#def has_active_orders
|
||||
#object.has_active_orders?
|
||||
|
||||
@@ -9,7 +9,7 @@ class UserExtendedListSerializer < Qwaiter::Serializer
|
||||
# user ids for facebook pictures
|
||||
self.root = :list
|
||||
embed :ids, include: true
|
||||
attributes :extended_version, :state, :needs_help, :needs_payment, :is_paid, :price,
|
||||
attributes :extended_version, :state, :needs_help, :needs_payment, :user_requests_closing, :is_paid, :price,
|
||||
:table_id, :table_number, :section_id, :user_ids, :supplier_id
|
||||
#:supplier_orders_in_process_count, :supplier_orders_placed_count
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class UserListSerializer < Qwaiter::Serializer
|
||||
# user ids for facebook pictures
|
||||
#embed :ids
|
||||
attributes :state, :needs_help, :needs_payment, :is_paid, :price, :table_id, :table_number, :section_id, :user_ids, :supplier_name
|
||||
attributes :state, :needs_help, :needs_payment, :user_requests_closing, :is_paid, :price, :table_id, :table_number, :section_id, :user_ids, :supplier_name
|
||||
|
||||
#def has_active_orders
|
||||
#object.has_active_orders?
|
||||
|
||||
Reference in New Issue
Block a user