def get_all_interests(): """Get all interests""" query = Interest.query.all() interest_list_dto = InterestsListDTO() interest_list_dto.interests = [interest.as_dto() for interest in query] return interest_list_dto
def create_or_update_user_interests(user_id, interests): user = UserService.get_user_by_id(user_id) user.create_or_update_interests(interests) # Return DTO. dto = InterestsListDTO() dto.interests = [i.as_dto() for i in user.interests] return dto
def create_or_update_project_interests(project_id, interests): project = ProjectService.get_project_by_id(project_id) project.create_or_update_interests(interests) # Return DTO. dto = InterestsListDTO() dto.interests = [i.as_dto() for i in project.interests] return dto
def get_interests(user: User) -> InterestsListDTO: dto = InterestsListDTO() dto.interests = [] for interest in Interest.query.all(): int_dto = interest.as_dto() if interest in user.interests: int_dto.user_selected = True dto.interests.append(int_dto) return dto