Advertisement
Mochinov

Untitled

Apr 4th, 2022
869
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. @celery_app.task
  2. def delete_users(delete_user_id: int, manager_id: int) -> None:
  3.     """ Удаляет пользователя из чата """
  4.  
  5.     chat_users = ChatUser.objects.filter(
  6.         id=delete_user_id,
  7.         is_delete=True,
  8.     )
  9.  
  10.     manager = User.objects.filter(id=manager_id).first()
  11.  
  12.     for user in chat_users:
  13.         if user.is_delete and user.user_deletion:
  14.             chat_tg_user = TgChatUser.objects.filter(
  15.                 tg_user__user = user.user,
  16.                 chat = user.chat,
  17.             )
  18.             User.objects.delete_user_from_chat(
  19.                 user=manager,
  20.                 chat_user=user,
  21.                 chat_tg_user=chat_tg_user,
  22.                 client=user,
  23.             )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement