Esempio n. 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
Esempio n. 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
Esempio n. 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,
     )
Esempio n. 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
Esempio n. 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'})
Esempio n. 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'})
Esempio n. 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
Esempio n. 8
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"},
     )
Esempio n. 9
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"},
     )
Esempio n. 10
0
 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
Esempio n. 11
0
 def post(self):
     body = api.payload
     api.schema_model('Movie', {**schema}).validate(body)
     controller = MovieController()
     movie = controller.insert(body)
     return movie, 201
Esempio n. 12
0
 def post(self):
     body = api.payload
     api.schema_model("ShowTime", {**schema}).validate(body)
     showtimes = ShowTimeController()
     return showtimes.insert(body), 201