def authenticate(self, username, password): user = user_service.find_by_username(username) if user is None: raise UserNotExist(username) if not user.check_password(password): raise WrongCredentials() return user
def update_group_progress(self, username, subject_name, group_id, data): tutor = self.find_tutor_by_username(username) tgs = self.find_tgs(tutor, subject_name, group_id) for cp_name in data: checkpoint = self.find_checkpoint_by_name(tgs, cp_name) for user_info in data[cp_name]: student = tgs.group.students.filter_by(user_id=user_info['user_id']).first() if student is None: raise UserNotExist(user_info['user_id']) Progress.query.filter_by(checkpoint_id=checkpoint.id, student_id=student.user_id).update(user_info['progress']) """ for user_info in data: for cp_name in user_info["progress"]: checkpoint = self.find_checkpoint_by_name(tgs, cp_name) student = tgs.group.students.filter_by(user_id=user_info['user_id']).first() if student is None: raise UserNotExist(user_info['user_id']) Progress.query.filter_by(checkpoint_id=checkpoint.id, student_id=student.user_id).update(user_info['progress'][cp_name]) """ db.session.commit()
def find_tutor_by_username(self, username): user = user_service.find_by_username(username) if user is None: raise UserNotExist(username) return user.tutor