コード例 #1
0
 def signal_DialogMsgList(self, with_user_pk, dialog_msg_list):
     data = []
     for d in dialog_msg_list:
         data.append(
             helpers.mongo_to_dict_helper2(d)
         )
     self.sendMsgToSelf('dialog_msg_list', {
         'dialog_with_user_pk': with_user_pk,
         'dialogs': data
     })
コード例 #2
0
 def signal_DialogList(self):
     dialogs = models.Dialog.objects(owner=self.user.owner)
     data = []
     for d in dialogs:
         data.append(
             helpers.mongo_to_dict_helper2(
                 d, fields=[
                     'owner', 'dialog_with_user', 'last_msg_timestamp',
                     'unreaded_count'])
         )
     self.sendMsgToSelf('dialog_list', data)
コード例 #3
0
 def signal_DialogMsg(self, with_user, dialog_msg, dialog, to_user_pk):
     data = helpers.mongo_to_dict_helper2(dialog_msg)
     print(data)
     self.sendMsgToAll('dialog_msg', {
         'dialog_msg': data,
         'dialog_with_user_pk': with_user.owner,
         'dialog_with_user': {
             'pk': with_user.owner,
             'username': with_user.username
         },
         'unreaded_count': dialog.unreaded_count
     }, to_user_pk)
コード例 #4
0
ファイル: websocket_so.py プロジェクト: ganap/so
 def signal_AllQueue(self):
     self.queue = self.get_or_create_SOQueue()
     if self.user.is_admin or self.user.is_moderator:
         print("MODERATOR")
         data = helpers.mongo_to_dict_helper2(self.queue)
         self.sendMsgToSelf('all_queue', data)
     else:
         if self.user.is_expert:
             field = 'assigned_to'
         else:
             field = 'user'
         # експерту и пациенту нужно отправить только то что ассоциировано с ним самим
         opened = []
         in_progress = []
         closed = []
         reopened = []
         processed_ = []
         for o in self.queue.opened:
             if o[field] == self.user.owner:
                 opened.append(o)
         for ip in self.queue.in_progress:
             if ip[field] == self.user.owner:
                 in_progress.append(ip)
         for c in self.queue.closed:
             if c[field] == self.user.owner:
                 closed.append(c)
         for r in self.queue.reopened:
             if r[field] == self.user.owner:
                 reopened.append(r)
         for r in self.queue.processed_:
             if r[field] == self.user.owner:
                 processed_.append(r)
         self.sendMsgToSelf(
             'all_queue',
             {
                 'opened': opened,
                 'in_progress': in_progress,
                 'closed': closed,
                 'reopened': reopened,
                 'processed_': processed_
             }
         )
コード例 #5
0
 def signal_AllQueue(self):
     self.queue = self.get_or_create_SOQueue()
     if self.user.is_admin or self.user.is_moderator:
         print("MODERATOR")
         data = helpers.mongo_to_dict_helper2(self.queue)
         self.sendMsgToSelf('all_queue', data)
     else:
         if self.user.is_expert:
             field = 'assigned_to'
         else:
             field = 'user'
         # експерту и пациенту нужно отправить только то что ассоциировано с ним самим
         opened = []
         in_progress = []
         closed = []
         reopened = []
         processed_ = []
         for o in self.queue.opened:
             if o[field] == self.user.owner:
                 opened.append(o)
         for ip in self.queue.in_progress:
             if ip[field] == self.user.owner:
                 in_progress.append(ip)
         for c in self.queue.closed:
             if c[field] == self.user.owner:
                 closed.append(c)
         for r in self.queue.reopened:
             if r[field] == self.user.owner:
                 reopened.append(r)
         for r in self.queue.processed_:
             if r[field] == self.user.owner:
                 processed_.append(r)
         self.sendMsgToSelf(
             'all_queue', {
                 'opened': opened,
                 'in_progress': in_progress,
                 'closed': closed,
                 'reopened': reopened,
                 'processed_': processed_
             })