コード例 #1
0
ファイル: manage.py プロジェクト: huichen90/tigereye-1
def testdata():
    """create test data."""
    from tigereye.models.cinema import Cinema
    from tigereye.models.movie import Movie
    print('start creating testdata.......')
    Cinema.create_test_data()
    Movie.create_test_data()
コード例 #2
0
ファイル: helper.py プロジェクト: 18636800170/movieApi
 def setUp(self):
     app = tigereye.create_app(TestConfig)
     # 将所有的logger关掉
     app.logger.disabled = True
     # 创建模拟客户端
     self.app = app.test_client()
     with app.app_context():
         db.create_all()
         Cinema.create_test_data(cinema_num=1, hall_num=3, play_num=3)
         Movie.create_test_data()
コード例 #3
0
 def setUp(self):
     app = tigereye.create_app(TestConfig)
     app.logger.disabled = True
     self.app = app.test_client()
     with app.app_context():
         from tigereye.models import db
         from tigereye.models.cinema import Cinema
         from tigereye.models.hall import Hall
         from tigereye.models.movie import Movie
         from tigereye.models.order import Order
         from tigereye.models.seat import Seat, PlaySeat
         from tigereye.models.play import Play
         db.create_all()
         Cinema.create_test_data(cinema_num=1, hall_num=3, play_num=3)
         Movie.create_test_data()
コード例 #4
0
ファイル: helper.py プロジェクト: huichen90/tigereye-1
 def setUp(self):
     """Creates the Flask application and the APIManager."""
     app = tigereye.create_app(TestConfig)
     app.logger.disabled = True
     self.flaskapp = app
     self.app = app.test_client()
     with app.app_context():
         from tigereye.extensions import db
         from tigereye.models.cinema import Cinema  # noqa
         from tigereye.models.hall import Hall  # noqa
         from tigereye.models.movie import Movie  # noqa
         from tigereye.models.play import Play  # noqa
         from tigereye.models.seat import Seat  # noqa
         from tigereye.models.seat import PlaySeat  # noqa
         from tigereye.models.order import Order  # noqa
         db.create_all()
         Cinema.create_test_data(cinema_num=1, hall_num=3, play_num=3)
         Movie.create_test_data()
コード例 #5
0
ファイル: cinema.py プロジェクト: 18636800170/movieApi
 def plays(self):
     cid = request.params["cid"]
     cinema = Cinema.get(cid)
     if not cinema:
         return Code.cinema_does_not_exist.request.args
     cinema.plays = Play.query.filter_by(cid=cid).all()
     for play in cinema.plays:
         play.movie = Movie.get(play.mid)
     return cinema
コード例 #6
0
 def ticket_info(self):
     orderno = request.params['orderno']
     order = Order.getby_orderno(orderno)
     if not order:
         return Code.order_does_not_exist, {'orderno': orderno}
     order.play = Play.get(order.pid)
     order.movie = Movie.get(order.play.mid)
     order.tickets = PlaySeat.getby_orderno(orderno)
     return order
コード例 #7
0
ファイル: cinema.py プロジェクト: huichen90/tigereye-1
 def plays(self):
     cid = request.params['cid']
     cinema = Cinema.get(cid)
     if not cinema:
         return Code.cinema_does_not_exist, {'cid': cid}
     cinema.plays = Play.query.filter_by(cid=cid).all()
     if not cinema:
         return Code.cinema_does_not_exist, {'cid': cid}
     for play in cinema.plays:
         play.movies = Movie.get(play.mid)
     return cinema
コード例 #8
0
 def setUp(self):
     app = tigereye.create_app(Testconfig)
     # 关掉日志
     app.logger.disabled = True
     # 不用 不走网络io也能启动接口,创建了test_client
     self.app = app.test_client()
     # 这句和** with open() as f一样,是Python提供的语法糖,可以为提供上下文环境省略简化一部分工作。
     # 这里就简化了其压栈和出栈操作,请求线程创建时,Flask会创建应用上下文对象,
     # 并将其压入flask._app_ctx_stack**的栈中,然后在线程退出前将其从栈里弹出。
     with app.app_context():  #创建了一堆数据库
         from tigereye.models import db
         from tigereye.models.cinema import Cinema
         from tigereye.models.hall import Hall
         from tigereye.models.movie import Movie
         from tigereye.models.play import Play
         from tigereye.models.seat import Seat
         from tigereye.models.order import Order
         from tigereye.helper.code import Code
         db.create_all()
         Cinema.create_test_data(cinema_num=1, hall_num=3, play_num=3)
         Movie.create_test_data()
コード例 #9
0
ファイル: cinema.py プロジェクト: Elegant-Smile/flask
    def plays(self):
        # 使用Request.Params["id"]来获取参数是一种比较有效的途径。
        cid = request.params['cid']
        cinema = Cinema.get(cid)
        if not cinema:
            return Code.cinema_does_not_exist, request.args
        cinema.plays = Play.query.filter_by(cid=cid).all()
        for play in cinema.plays:
            play.movie = Movie.get(play.mid)

        # 为啥返回的是cinema
        return cinema
コード例 #10
0
def testdata():
    from tigereye.models.cinema import Cinema
    from tigereye.models.movie import Movie
    Cinema.create_test_data()
    Movie.create_test_data()
コード例 #11
0
ファイル: movie.py プロジェクト: huichen90/tigereye-1
 def get(self):
     mid = request.params['mid']
     movie = Movie.get(mid)
     return movie
コード例 #12
0
    def create_test_data(cls,cinema_num = 3,hall_num = 3,play_num = 10):
            import  time


            from tigereye.models.hall import Hall
            from tigereye.models.seat import Seat,PlaySeat,SeatType
            from tigereye.models.movie import Movie
            from tigereye.models.cinema import Cinema
            from tigereye.models.play import Play
            from faker import Faker
            import math
            from datetime import datetime
            start_time = time.time()
            HALL_SEATS_NUM = 25
            faker = Faker('zh_CN')
            cinemas = []
            for i in range(1,cinema_num+1):
                cinema = Cinema()
                cinema.name = '%s影城' % faker.name()
                cinema.address = faker.address()
                cinema.status = 1
                cinema.put()
                cinemas.append(cinema)
            Cinema.commit()
            halls = []
            plays = []

            for cinema in cinemas:
                for n in range(1,hall_num+1):
                    hall = Hall()
                    hall.cid = cinema.cid
                    hall.name = '%s 号厅' % n
                    hall.screen_type = "IMAX"
                    hall.audio_type = '杜比环绕'
                    hall.seats_num = HALL_SEATS_NUM
                    hall.status = 1
                    hall.put()
                    halls.append(hall)
                Hall.commit()

            for hall in halls:
                hall.seats = []


                for x in range(1,HALL_SEATS_NUM+1):
                    seat = Seat()
                    seat.cid = hall.cid
                    seat.hid = hall.hid
                    seat.x = x % 5 or 5
                    seat.y = math.ceil(x / 5)
                    seat.row = '%s 排' % seat.x
                    seat.column = '%s 列' % seat.y
                    seat.seat_type = SeatType.single.value

                    seat.status = SeatStatus.ok.value
                    seat.put()
                    hall.seats.append(seat)
                Seat.commit()



                for p in range(1,play_num+1):
                     play = Play()
                     play.cid = hall.cid
                     play.hid = hall.hid
                     play.mid = p
                     play.start_time = datetime.now()
                     play.duration = 3600
                     play.price_type = 1
                     play.price = 70000
                     play.market_price = 5000
                     play.lowest_price = 3000
                     play.status = 1
                     play.put()
                     play.hall = hall
                     plays.append(play)
                Play.commit()
            for play in plays:


                for seat in play.hall.seats:
                     ps = PlaySeat()
                     ps.pid = play.pid
                     ps.copy(seat)
                     ps.put()


                PlaySeat.commit()


            for i in range(10):
                m = Movie()
                m.name = '电影名称 %s' % (i +1)
                m.language = '英文'
                m.subtitle = '中文'
                m.mode = '数字'
                m.vision = '3D'
                m.screen_size = 'IMAX'
                m.introduction = '哈哈哈'
                m.status = 1
                m.save()
            print('create test data done! cost %s seconds' % (time.time() - start_time))
コード例 #13
0
ファイル: manage.py プロジェクト: ljxproject/tigereye
def testdata():
    Movie.create_test_data(100)
    Cinema.create_test_data(cinema_num=10)
コード例 #14
0
ファイル: movie.py プロジェクト: ljxproject/tigereye
 def get(self):
     mid = request.args['mid']
     movie = Movie.get(mid)
     if not movie:
         return Code.movie_does_not_exist
     return movie