Exemplo n.º 1
0
 def group_create(self, name, user):
     """Создание объекта группы в базе данных."""
     group = ChatGroup(name=name)
     group.save()
     participant = GroupParticipant(user=user, group=group)
     participant.save()
     return {
         'id': group.id,
         'name': group.name,
         'link': group.link
     }
 async def connect(self):
     await super().connect()
     self.group_id = self.scope['url_route']['kwargs']['group_id']
     self.group = await self.get_group_by_id(self.group_id)
     self.group_name = ChatGroup.get_group_name(self.group_id)
     await self.channel_layer.group_add(self.group_name, self.channel_name)
Exemplo n.º 3
0
 def group_create(self, name, user):
     group = ChatGroup(name=name)
     group.save()
     participant = GroupParticipant(user=user, group=group)
     participant.save()
     return {'id': group.id, 'name': group.name, 'link': group.link}
Exemplo n.º 4
0
 async def connect(self):
     await super().connect()
     self.channel = ChatGroup.user_channel_name(self.scope['user'].id)
     await self.channel_layer.group_add(self.channel, self.channel_name)