def broadcast_music_event(): admin = User.objects.filter(is_superuser=True).first() public_channel = Channel.get_public_channel() count = 0 message = { "type": SOCKET_MESSAGE_TYPE.music_event, "music": len(Playlist.pendings()) } try: send_message_to_mobile(admin.pk, message) except Exception as e: pass
def broadcast_table_changes(table_pk): admin = User.objects.filter(is_superuser=True).first() public_channel = Channel.get_public_channel() count = 0 message = { "type": SOCKET_MESSAGE_TYPE.table, "table": table_pk, 'to': public_channel.pk } try: send_message_to_mobile(admin.pk, message) except Exception as e: pass
def broadcast_events(events): admin = User.objects.filter(is_superuser=True).first() public_channel = Channel.get_public_channel() count = 0 for event in events: message = { "type": SOCKET_MESSAGE_TYPE.event, "event": event.pk, 'to': public_channel.pk } try: send_message_to_mobile(admin.pk, message) count += 1 except Exception as e: pass return count
def clear(self): if self.order and self.order.state != ORDER_STATE.archived: order = self.order order.details['customers']['male'] = self.male order.details['customers']['female'] = self.female order.archive() order.save() self.male = 0 self.female = 0 for attendee in self.user.attendees.all(): attendee.channel.messages.filter(poster=self.user).delete() pc = Channel.get_public_channel() pc.messages.filter(poster=self.user).delete() # TODO: Clean bookings for booking in self.requested_bookings.all(): booking.archive() for booking in self.received_bookings.all(): booking.archive() self.cleared = timezone.now()
def get_channel(self, to=None): if to is None: return Channel.get_public_channel() else: to_channel = Channel.objects.get(pk=to) return to_channel
def create_channels_for_new_user(sender, instance, created, **kwargs): if created: # Create public channel channel = Channel.get_public_channel() channel.attendees.create(user=instance)