def update_workshop(id): body = request.get_json() workshop = Workshop.get_by_id(id) new_workshop = workshop.update_workshop(body['title'], body['duration'], body['price'], body['date'], body['max_people'], body['description'], body['category_info']) new_categories = Workshop.get_category_by_name(body['category_info']) return jsonify(new_workshop.to_dict(new_categories))
def get_workshops(): workshops = Workshop.get_all() workshops_to_dict = [] for workshop in workshops: workshops_to_dict.append(workshop.to_dict()) return jsonify(workshops_to_dict), 200
def add_workshop(id): user_psychologist = User_psychologist.get_by_id(id) body = request.get_json() new_workshop = Workshop( title = body.get("title"), duration = body.get("duration"), price = body.get("price"), date = body.get("date"), max_people = body.get("max_people"), description = body.get("description"), user_psychologist_id = user_psychologist.id, ) new_workshop.add(body.get("category_info")) return jsonify(new_workshop.to_dict()), 200
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_workshop(psy_id, id): workshop = Workshop.get_by_id(id) workshop.delete() return workshop.to_dict(), 200
def get_target_workshop(id): target_workshop = Workshop.get_by_id(id) return jsonify(target_workshop.to_dict()), 200
def get_psychologist_workshops(id): workshops = Workshop.get_workshop_by_psychologist_id(id) workshops_to_dict = [] for workshop in workshops: workshops_to_dict.append(workshop.to_dict()) return jsonify(workshops_to_dict), 200