コード例 #1
0
    def get(self, id_movie):

        if self.request.GET['type'] == "f263d9a8b7cb4a9e573c18e5b9e15091":
            route = "/tv/" + id_movie
        else:
            route = "/movies/" + id_movie

        user = users.get_current_user()
        if user:
            if self.request.GET['list'] == "d78986947356ddd37b43d57df289dee9":
               user_default_list = list_mgt.get_favorite(user.email())
            else:
                user_default_list = list_mgt.get_watchlist(user.email())

            movie_to_add_default_list = movielist_mgt.get_item(user.email(), user_default_list.key.id(), int(id_movie))
            if not movie_to_add_default_list:
                movie_to_add_default_list = movielist_mgt.create_empty_movie_list()
                movie_to_add_default_list.user = user.email()
                movie_to_add_default_list.id_list = user_default_list.key.id()
                movie_to_add_default_list.id_movie = int(id_movie)
                if "movies" in route:
                    movie_to_add_default_list.type_movie = "Movie"
                else:
                    movie_to_add_default_list.type_movie = "TV Show"

                # Chk
                if len(movie_to_add_default_list.user) < 1:
                    self.redirect(route + "?error=C4CA4238A0B923820DCC509A6F75849B")
                    return

                if not movie_to_add_default_list.id_movie:
                    self.redirect(route + "?error=C81E728D9D4C2F636F067F89CC14862C")
                    return
                # Save
                movielist_mgt.update(movie_to_add_default_list)
                if self.request.GET['list'] == "d78986947356ddd37b43d57df289dee9":
                    self.redirect(route + "?info=A87FF679A2F3E71D9181A67B7542122C")
                else:
                    self.redirect(route + "?info=34173cb38f07f89ddbebc2ac9128303f")
            else:
                self.redirect(route + "?error=ECCBC87E4B5CE2FE28308FD9F2A7BAF3")
        else:
            self.redirect("/")
コード例 #2
0
    def get(self):
        user = users.get_current_user()
        access_link = users.create_logout_url("/")

        if user:
            fav_list_user = list_mgt.get_favorite(user.email())
            if not fav_list_user:
                fav_list_user = list_mgt.create_empty_list()
                fav_list_user.user = user.email()
                fav_list_user.name_list = "Favorites"
                fav_list_user.description_list = "Your favorites of always"
                list_mgt.update(fav_list_user)

            watch_list_user = list_mgt.get_watchlist(user.email())
            if not watch_list_user:
                watch_list_user = list_mgt.create_empty_list()
                watch_list_user.user = user.email()
                watch_list_user.name_list = "Watchlist"
                watch_list_user.description_list = "To see on your next free day"
                list_mgt.update(watch_list_user)

            api_key = TMDB.tmdb_api_key
            url = "https://api.themoviedb.org/3/movie/now_playing?api_key=" + api_key + "&language=en-US"
            result = urlfetch.fetch(url, method=urlfetch.GET)
            json_response = json.loads(result.content)
            movies = json_response.get("results")

            template_values = {
                "info": AppInfo,
                "user": user,
                "access_link": access_link,
                "movies": movies,
                "popular": False
            }

            jinja = jinja2.get_jinja2(app=self.app)
            self.response.write(jinja.render_template("movies/movies.html", **template_values))
        else:
            self.redirect("/")
コード例 #3
0
    def get(self, id_movie):

        if self.request.GET['type'] == "f263d9a8b7cb4a9e573c18e5b9e15091":
            route = "/tv/" + id_movie
        else:
            route = "/movies/" + id_movie

        user = users.get_current_user()
        if user:
            if self.request.GET['list'] == "d78986947356ddd37b43d57df289dee9":
                user_default_list = list_mgt.get_favorite(user.email())
            else:
                user_default_list = list_mgt.get_watchlist(user.email())
            movie_to_delete_default_list = movielist_mgt.get_item(user.email(), user_default_list.key.id(), int(id_movie))
            if movie_to_delete_default_list:
                # Delete
                movie_to_delete_default_list.key.delete()
                if self.request.GET['list'] == "d78986947356ddd37b43d57df289dee9":
                    self.redirect(route + "?info=E4DA3B7FBBCE2345D7772B0674A318D5")
                else:
                    self.redirect(route + "?info=6ea9ab1baa0efb9e19094440c317e21b")
                return
        else:
            self.redirect("/")
コード例 #4
0
    def get(self, id_tvshow):
        try:
            message_success = Message.message.get(self.request.GET['info'])
        except:
            message_success = None

        try:
            message_danger = Message.message.get(self.request.GET['error'])
        except:
            message_danger = None

        user = users.get_current_user()
        access_link = users.create_logout_url("/")

        if not user:
            self.redirect("/")

        api_key = TMDB.tmdb_api_key
        url_movie = "https://api.themoviedb.org/3/tv/" + id_tvshow + "?api_key=" + api_key + "&language=en-US"
        result = urlfetch.fetch(url_movie, method=urlfetch.GET)
        tvshow = json.loads(result.content)

        # Check if the movie is in favorite list user
        fav_list = list_mgt.get_favorite(user.email())
        isfav_tv = movieList_mgt.get_item(user.email(), fav_list.key.id(),
                                          int(id_tvshow))

        # Check if the movie is in watchlist user
        watchlist_list = list_mgt.get_watchlist(user.email())
        is_pending_tv = movieList_mgt.get_item(user.email(),
                                               watchlist_list.key.id(),
                                               int(id_tvshow))

        # Check and if exists, get the user review for this movie
        my_review = review_mgt.get_review(user.email(), int(id_tvshow))
        # We have to format dates of the review user for template
        if my_review:
            my_review_date_format = review_mgt.format_date(my_review.date)
        else:
            my_review_date_format = None

        # Check and it exists, ge the others users reviews
        others_reviews = review_mgt.get_others_reviews(user.email(),
                                                       int(id_tvshow))
        if others_reviews:
            others_reviews = list(others_reviews)
            # Format the users dates reviews for template
            others_reviews_dates_format = review_mgt.format_dates(
                others_reviews)
        else:
            others_reviews_dates_format = None

        # Get the user lists
        my_lists = list_mgt.get_user_lists(user.email())
        my_lists = list(my_lists)

        # Returns the lists in which the movie is found
        movie_lists = movieList_mgt.get_all_lists(user.email(), int(id_tvshow))
        movie_lists = list(movie_lists)
        # Get only the lists identifier to match withe the __contains__ function in template
        lists_movies = []
        for movie_list in movie_lists:
            lists_movies.append(movie_list.id_list)

        template_values = {
            "info": AppInfo,
            "access_link": access_link,
            "user": user,
            "tvshow": tvshow,
            "my_review": my_review,
            "my_review_date": my_review_date_format,
            "other_reviews": others_reviews,
            "others_reviews_dates": others_reviews_dates_format,
            "is_favorite": isfav_tv,
            "is_pending": is_pending_tv,
            "my_lists": my_lists,
            "lists_select": lists_movies,
            "message_success": message_success,
            "message_danger": message_danger,
        }
        jinja = jinja2.get_jinja2(app=self.app)
        self.response.write(
            jinja.render_template("tv/reviews.html", **template_values))