コード例 #1
0
ファイル: main.py プロジェクト: ericgrogers/DPW
    def get(self):
        p = PageFormView()  # create an instance of PageFormView

        #input format is 'type', 'name/value', 'placeholder'
        p.inputs = [['text', 'search', 'Find a Movie'], ['submit', 'Search']]  # create the form inputs
        self.response.write(p.compile_view())  # compile the initial page load

        if self.request.GET:  # if the GET method is called
            if 'search' in self.request.GET:  # check the url for a 'search' parameter
                try:  # if search was found, try the following
                    mm = MovieModel()  # create an instance of MovieModel
                    mm.search = self.request.GET['search']  # set the MovieModel search attribute the the search value
                    mm.get_list()  # call the get_list method from MovieModel
                    mv = MovieView()  # create an instance of MovieView
                    mv.mdo = mm.dos  # set the MovieView mdo (movie data object) to the value of MovieModel dos (data objects)
                    self.response.write(mv.list_content)  # write the results of calling the MovieView list_content method
                except:  # otherwise
                    if not self.request.GET['search']:  # if a value for search is not found in the url
                        self.response.write(p.error1)  # tell the user they can't submit blanks
                    else:  # otherwise
                        self.response.write(p.error2)  # tell the user that their search was unsuccessful
            elif 'i' in self.request.GET:  # otherwise, if the parameter 'i' is found in the url
                try:  # try the following
                    mm = MovieModel()  # create an instance of MovieModel
                    mm.id = self.request.GET['i']  # set the MovieModel id to the value of the url parameter 'i'
                    mm.get_movie()  # call the MovieModel get_movie method
                    mv = MovieView()  # create an instance of MovieView
                    mv.md = mm.movie_data  # set the MovieView md (movie data) to the MovieModel movie_data
                    self.response.write(mv.movie_content)  # write the MovieView movie_content to the page
                except:  # otherwise
                    self.response.write(p.error2)  # tell the user that their search was unsuccessful
            else:  # otherwise
                self.response.write(p.error2)  # tell the user that their search was unsuccessful
コード例 #2
0
ファイル: view.py プロジェクト: nogever/imdb-top-ten
    def get(self):
        dates = MovieModel.get_all_dates()

        return jsonify({
            'success': True,
            'dates': dates
        })
コード例 #3
0
ファイル: view.py プロジェクト: nogever/imdb-top-ten
    def get(self):
        allMovies = MovieModel.get_all()

        return jsonify({
            'success': True,
            'movies': movies
        })
コード例 #4
0
    def test_select(self):
        movies = MovieModel.where().select()

        for movie in movies:
            if movie.movieid == "9999999991": pass
            elif movie.movieid == "9999999992": pass
            else:
                self.assertEquals(movie.movieid, "9999999993")
                self.assertEquals(movie.mname, u"狗十三")
コード例 #5
0
ファイル: view.py プロジェクト: nogever/imdb-top-ten
    def get(self):
        queried_date = '2015-08-05'
        queried_date_id = 1
        movies = MovieModel.top_ten(queried_date_id)

        return jsonify({
            'success': True,
            'movies': movies
        })
コード例 #6
0
def create_movie_instance(
        movieid,
        mname,
        director,
        editor,
        actor,
        mtype,
        countryOrLocation,
        language,
        date,
        duration,
        othername,
        IMDb,
        introduction,
        allActors,
        numOfEvaluator,
        star5,
        star4,
        star3,
        star2,
        star1
    ):
    movie = MovieModel()

    movie.movieid = movieid
    movie.mname = mname
    movie.director = director
    movie.editor = editor
    movie.actor = actor
    movie.mtype = mtype
    movie.countryOrLocation = countryOrLocation
    movie.language = language
    movie.date = date
    movie.duration = duration
    movie.othername = othername
    movie.IMDb = IMDb
    movie.introduction = introduction
    movie.allActors = allActors
    movie.numOfEvaluator = numOfEvaluator
    movie.star5 = star5
    movie.star4 = star4
    movie.star3 = star3
    movie.star2 = star2
    movie.star1 = star1

    movie.save()
    return movie
コード例 #7
0
    def test_count(self):
        cnt = MovieModel.where(introduction=u"很好看的电影").count()

        self.assertEquals(1, cnt)
コード例 #8
0
    def test_limit(self):
        movies = MovieModel.where(introduction=u"很好看的电影").limit(2).select()

        cnt = 0
        for movie in movies: cnt += 1
        self.assertEquals(1, cnt)
コード例 #9
0
    def test_update(self):
        MovieModel.where(movieid="9999999991").update(mname=u"海的女儿")
        movie = MovieModel.where(movieid="9999999991").select().next()

        self.assertEquals(movie.mname, u"海的女儿")
コード例 #10
0
    def test_instance(self):
        movie = MovieModel.where(movieid="9999999991").select().next()

        self.assertEquals(movie.movieid, "9999999991")
        self.assertEquals(movie.mname, u"海王")
コード例 #11
0
 def setUp(self):
     if list(MovieModel.where(movieid="9999999991").select()) == []:
         create_movie_instance(
             "9999999991",
             u"海王",
             u"温子仁",
             u"编剧",
             u"罗钥轩/海王",
             u"玄幻",
             u"中国",
             u"中文",
             u"2018-12-2",
             145,
             u"海的女儿",
             u"www.123.com",
             u"很好看的电影",
             u"师毓洁/智障",
             3466,
             1531,
             245,
             456,
             1000,
             234
         )
     if list(MovieModel.where(movieid="9999999992").select()) == []:
         create_movie_instance(
             "9999999992",
             u"龙猫",
             u"导演2",
             u"编剧2",
             u"罗钥轩/龙",
             u"动漫",
             u"日本",
             u"日语",
             u"2018-12-23",
             120,
             u"dragon",
             u"www.456.com",
             u"很不好看的电影",
             u"师毓洁/猫",
             5000,
             2300,
             40,
             60,
             1300,
             1300
         )
     if list(MovieModel.where(movieid="9999999993").select()) == []:
         create_movie_instance(
             "9999999993",
             u"狗十三",
             u"曹保平",
             u"编剧3",
             u"张雪迎/十三",
             u"爱情",
             u"中国",
             u"中文",
             u"2018-12-25",
             118,
             u"狗狗十三啦",
             u"www.789.com",
             u"冷冷冷冷了很好看的电影",
             u"师毓洁/狗子",
             1800,
             300,
             600,
             300,
             500,
             100
         )