def add_participant(uuid, participants: AddParticipantsRequest, current_user: User = Depends(get_current_user)): added_user = [] try: quiz = current_user.created_quizzes.where(Quiz.uuid == uuid).get() except (peewee.DoesNotExist, peewee.DataError): return {'code': -2, 'msg': 'invalid quiz'} if quiz.public: return {'code': -12, 'msg': 'you cant add person to private quiz'} for email in participants.participants: try: user = User.select().where(User.email == email).get() except peewee.DoesNotExist: pass else: try: with database.atomic(): QuizUsers.create(quiz=quiz, user=user) except peewee.IntegrityError: pass else: added_user.append(user.email) return {'data': added_user}
def override_get_current_user(): return User.select().where(User.email == '*****@*****.**')
def users(): u = User.select().dicts() return {'row': list(u)}
def get_user_by_email(email): try: return User.select().where(User.email == email).get() except peewee.DoesNotExist: raise HTTPException(status_code=401, detail="Incorrect username")