def add_search_workshop(id): user_company = User_company.get_by_id(id) body = request.get_json() new_search_workshop = Search_workshop(duration=body.get("duration"), max_price=body.get("price"), date=body.get("date"), max_people=body.get("max_people"), user_company_id=user_company.id, category_id=body.get("category_id")) new_search_workshop.add() return jsonify(new_search_workshop.to_dict()), 201
def get_company_workshops(id): workshops = Search_workshop.get_workshop_by_company_id(id) workshops_to_dict = [] for workshop in workshops: workshops_to_dict.append(workshop.to_dict()) return jsonify(workshops_to_dict), 200
def get_search_workshops(): search_workshops = Search_workshop.get_all() search_workshops_to_dict = [] for search_workshop in search_workshops: search_workshops_to_dict.append(search_workshop.to_dict()) return jsonify(search_workshops_to_dict), 200
def update_search_workshop(com_id, id): body = request.get_json() search_workshop = Search_workshop.get_by_id(id) new_search_workshop = search_workshop.update_search_workshop(body['title'], body['duration'], body['price'], body['date'], body['max_people'], body['category_id']) return jsonify(new_search_workshop.to_dict())
def search_bar(id): body = request.get_json() title = body.get("search", None) user = User.get_by_id(id) if user.is_psychologist: search_workshops = Search_workshop.get_search_workshop_for_search_bar(title) search_workshops_to_dict = [] for search_workshop in search_workshops: search_workshops_to_dict.append(search_workshop.to_dict()) return jsonify(search_workshops_to_dict), 200 workshops = Workshop.get_workshop_for_search_bar(title) return jsonify([workshop.to_dict() for workshop in workshops]), 200
def delete_one_search_workshop(id): search_workshop = Search_workshop.get_search_workshop_by_id(id) search_workshop.delete() return "Your search has been deleted", 200
def delete_one_search_workshop(com_id, id): search_workshop = Search_workshop.get_search_workshop_by_id(id) search_workshop.delete() return search_workshop.to_dict(), 200