better broadcasting for user

This commit is contained in:
2012-12-01 16:12:04 +01:00
parent a14687d568
commit 926be8ec48
7 changed files with 50 additions and 17 deletions
+23 -7
View File
@@ -126,6 +126,29 @@ class List
end
end
def move_to_table! to_table
UserTableMove.create list: self, from_table_id: table_id, to_table: to_table
self.table = to_table
self.section_id = to_table.section_id
if save
for user_id in user_ids
broadcast_user user_id, 'list_changed_table', list_id: id, table: to_table, section_title: to_table.section.try(:title)
end
broadcast_supplier supplier_id, 'list_changed_table', list_id: id, table: to_table, section_title: to_table.section.try(:title)
end
end
def needs_help!
self.needs_help = true
if save
for user_id in user_ids
broadcast_user user_id, 'list_needs_help', id: id
end
broadcast_supplier(supplier_id, 'list_needs_help', id: id)
end
end
def set_price
list_total = 0.0
for order in orders
@@ -162,13 +185,6 @@ class List
order
end
def move_to_table to_table
UserTableMove.create list: self, from_table_id: table_id, to_table: to_table
self.table = to_table
self.section_id = to_table.section_id
save
end
def as_json(*args)
super.merge(table_number: table_number)
end