def _get_user(self, member): try: return User.objects.get({'_id': member.id}) except User.DoesNotExist: user = User(user_id=member.id, name=member.name) user.save() return user
def _add_ctf_member(self, user, ctf): member = self._get_member(user.id) if not member: member = User(user_id=user.id, name=user.name) if not ctf in member.ctfs: member.ctfs.append(ctf) member.save() return member
def create_user(user_in: UserIn): user = User(first_name=user_in.first_name, last_name=user_in.last_name, user_name=user_in.user_name, email=user_in.email, password=user_in.password) try: user.save() return user except: return False
def update_user_by_chat_id(chat_id, first_name, last_name, username): """ Обновление информации о пользователе """ try: us = User.objects.get(chat_id=chat_id) except DoesNotExist: us = User(chat_id=chat_id) us.first_name = first_name us.last_name = last_name us.username = username try: us.save() except Exception: pass