예제 #1
0
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
예제 #2
0
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
예제 #3
0
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
예제 #4
0
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())
예제 #5
0
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
예제 #6
0
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
예제 #7
0
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