diff --git a/osinaweb/support/__pycache__/consumers.cpython-310.pyc b/osinaweb/support/__pycache__/consumers.cpython-310.pyc index da175874..ef7c3e3a 100644 Binary files a/osinaweb/support/__pycache__/consumers.cpython-310.pyc and b/osinaweb/support/__pycache__/consumers.cpython-310.pyc differ diff --git a/osinaweb/support/consumers.py b/osinaweb/support/consumers.py index d9a19e56..8805ba26 100644 --- a/osinaweb/support/consumers.py +++ b/osinaweb/support/consumers.py @@ -18,6 +18,22 @@ class TicketRoomConsumer(WebsocketConsumer): self.ticket_id = self.scope['url_route']['kwargs']['ticket_id'] self.ticket = get_object_or_404(Ticket, id=self.ticket_id) self.ticket_number = self.ticket.ticket_number + + existing_connection = TicketConnection.objects.filter(ticket=self.ticket, user=self.user, terminated_at__isnull=True).delete() + TicketConnection.objects.create( + ticket=self.ticket, + user=self.user, + date=datetime.now() + ) + staff_profile = StaffProfile.objects.filter(user=self.user).first() + if staff_profile: + if not TicketStaff.objects.filter(staff=staff_profile, ticket=self.ticket).exists(): + TicketStaff.objects.create( + staff=staff_profile, + ticket=self.ticket, + date_added=datetime.now() + ) + async_to_sync(self.channel_layer.group_add)( self.ticket_number, self.channel_name )