コード例 #1
0
    def insert(self, kwargs):
        cinema_hall = find_or_404(
            self.db, CinemaHall, id=kwargs.get('cinema_hall'))

        movie = find_or_404(self.db, Movie, id=kwargs.get('movie_id'))
        # check where cinemahall will be available for
        # the showtime period given the movie length
        if self.db.execute(self.instance.clean(kwargs)):
            raise ValidationError('error', payload={
                                  'message': f"Cinema hall {cinema_hall.name} already occupied for the showtime {kwargs.get('show_date_time')}"})
        return super().insert(kwargs)
コード例 #2
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
コード例 #3
0
    def insert(self, kwargs):
        cinema_hall = find_or_404(self.db,
                                  CinemaHall,
                                  id=kwargs.get("cinema_hall"))

        # check if movie exists
        find_or_404(self.db, Movie, id=kwargs.get("movie_id"))

        # check where cinemahall will be available for
        # the showtime period given the movie length
        if self.db.execute(self.instance.clean(kwargs)):
            raise ValidationError(
                "error",
                payload={
                    "message":
                    f"Cinema hall {cinema_hall.name} already occupied for the showtime {kwargs.get('show_datetime')}"
                },
            )
        return super().insert(kwargs)
コード例 #4
0
 def update(self, id, record, operator='OR', serialize=False):
     find_or_404(self.db, self.table, id=id)
     query = self.instance.update(id, operator, **record)
     return self.dict_to_tuple(self.db.execute(query, True), serialize)
コード例 #5
0
 def validate_showtime(self, showtime):
     return find_or_404(self.db, ShowTime, id=showtime)