コード例 #1
0
 def put(self, cinema_id):
     body = api.payload
     schema["required"] = ["seats"]
     api.schema_model("cinema", {**schema}).validate(body)
     seats = body.pop("seats")
     cinema = find_or_404(current_app.db, CinemaHall, id=cinema_id)
     seats_dict = SeatController().insert(process_seats(seats, cinema.id))
     return {"seats": seats_dict, **cinema._asdict()}, 200
コード例 #2
0
 def post(self):
     body = api.payload
     api.schema_model("cinema", {**schema}).validate(body)
     seats = body.pop("seats")
     controller = CinemaController()
     cinema = controller.insert(body)[0]
     seats_dict = process_seats(seats, cinema.get("id"))
     return {"seats": SeatController().insert(seats_dict), **cinema}, 201
コード例 #3
0
 def put(self, showtime_id):
     body = api.payload
     api.schema_model("ShowTime", {**schema}).validate(body)
     showtimes = ShowTimeController()
     return (
         showtimes.update(id=showtime_id, record=body, serialize=True),
         200,
     )
コード例 #4
0
 def post(self):
     body = api.payload
     api.schema_model('cinema', {**schema}).validate(body)
     seats = body.pop('seats')
     controller = CinemaController()
     cinema = controller.insert(body)[0]
     seats_dict = process_seats(seats, cinema.get('id'))
     return {'seats': SeatController().insert(seats_dict), **cinema}, 201
コード例 #5
0
 def post(self):
     request_data = api.payload
     api.schema_model('User', {**user_login_schema}).validate(request_data)
     controller = UserController()
     user = controller.find_one(email=request_data.get('email'))
     if user and check_password_hash(user.password,
                                     request_data['password']):
         token = generate_token(user)
         return {'token': token, **user._asdict()}, 200
     raise ValidationError(message='error',
                           status_code=401,
                           payload={'message': 'Invalid credentials'})
コード例 #6
0
 def post(self):
     user = api.payload
     api.schema_model('User', {**user_schema}).validate(user)
     user['password'] = generate_password_hash(user['password'],
                                               method='sha256')
     controller = UserController()
     if not controller.find_one(email=user.get('email')):
         user = controller.insert(user)
         return user, 201
     raise ValidationError(
         message='error',
         status_code=400,
         payload={'message': 'User with email already exists'})
コード例 #7
0
    def post(self):
        body = api.payload or {}
        api.schema_model('Tickets', {**schema}).validate(body)
        body['user_id'] = request.user.id
        controller = TicketController()

        seats_ids = body.pop('seat_id')
        seat_list = seats_ids if type(seats_ids) is list else [seats_ids]

        seats = process_tickets_seats(body, seat_list)
        ticket = controller.insert(seats, seat_id=seat_list, **body)

        return ticket, 201
コード例 #8
0
ファイル: auth.py プロジェクト: kimbugp/movie-bookings
 def post(self):
     request_data = api.payload
     api.schema_model("User", {**user_login_schema}).validate(request_data)
     controller = UserController()
     user = controller.find_one(email=request_data.get("email"))
     if user and check_password_hash(user.password,
                                     request_data["password"]):
         token = generate_token(user)
         return {"token": token, **user._asdict()}, 200
     raise ValidationError(
         message="error",
         status_code=401,
         payload={"message": "Invalid credentials"},
     )
コード例 #9
0
ファイル: auth.py プロジェクト: kimbugp/movie-bookings
 def post(self):
     user = api.payload
     api.schema_model("User", {**user_schema}).validate(user)
     user["password"] = generate_password_hash(user["password"],
                                               method="sha256")
     controller = UserController()
     if not controller.find_one(email=user.get("email")):
         user = controller.insert(user)
         return user, 201
     raise ValidationError(
         message="error",
         status_code=400,
         payload={"message": "User with email already exists"},
     )
コード例 #10
0
ファイル: movies.py プロジェクト: vadotey/movie-bookings
 def put(self, movie_id):
     body = api.payload
     api.schema_model('movie', {**schema}).validate(body)
     controller = MovieController()
     return controller.update(id=movie_id, record=body, serialize=True), 200
コード例 #11
0
ファイル: movies.py プロジェクト: vadotey/movie-bookings
 def post(self):
     body = api.payload
     api.schema_model('Movie', {**schema}).validate(body)
     controller = MovieController()
     movie = controller.insert(body)
     return movie, 201
コード例 #12
0
 def post(self):
     body = api.payload
     api.schema_model("ShowTime", {**schema}).validate(body)
     showtimes = ShowTimeController()
     return showtimes.insert(body), 201