예제 #1
0
def update_book():
    if current_user is not None and hasattr(current_user, "id"):
        # the date and time come as string, so I have to parse them and transform them in python datetime
        #
        reservation_date = request.form.get("reservation_date")
        py_datetime = datetime.datetime.strptime(reservation_date,
                                                 "%d/%m/%Y %H:%M")
        #
        people_number = int(request.form.get("people_number"))
        #
        reservation_id = int(request.form.get("reservation_id"))

        new_book = BookingServices.update_book(
            reservation_id,
            current_user,
            py_datetime,
            people_number,
            request.form.get("friends"),
        )
        reservations_as_list = UserService.get_customer_reservation(
            None, None, current_user.id)

        form = ReservationForm()
        return render_template(
            "user_reservations.html",
            reservations_as_list=reservations_as_list,
            my_date_formatter=my_date_formatter,
            new_book=new_book,
            form=form,
        )
예제 #2
0
    def test_reservation_as_list(self, client):
        """
        Test get reservation customer list
        """
        user = db.session.query(User).filter_by(
            email="*****@*****.**").first()
        raw_list = db.session.query(Reservation).filter_by(
            customer_id=user.id).all()
        reservations_as_list = UserService.get_customer_reservation(
            None, None, user.id)

        assert len(raw_list) == len(reservations_as_list)
예제 #3
0
def myreservation():

    # filter params
    fromDate = request.args.get("fromDate", type=str)
    toDate = request.args.get("toDate", type=str)

    reservations_as_list = UserService.get_customer_reservation(
        fromDate, toDate, current_user.id)
    form = ReservationForm()
    return render_template(
        "user_reservations.html",
        reservations_as_list=reservations_as_list,
        my_date_formatter=my_date_formatter,
        form=form,
    )
예제 #4
0
def delete_reservation(reservation_id):

    deleted = BookingServices.delete_book(reservation_id, current_user.id)

    reservations_as_list = UserService.get_customer_reservation(
        None, None, current_user.id)
    form = ReservationForm()
    return render_template(
        "user_reservations.html",
        reservations_as_list=reservations_as_list,
        my_date_formatter=my_date_formatter,
        deleted=deleted,
        _test="del_rest_test",
        form=form,
    )