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("/")
def get(self, id_list, id_movie): user = users.get_current_user() if user: list_select = List.get_by_id(int(id_list)) if list_select: movieList_to_delete = movielist_mgt.get_item( user.email(), int(id_list), int(id_movie)) if movieList_to_delete: # Delete movieList_to_delete.key.delete() sleep(1) self.redirect("/lists/" + id_list + "?info=4E732CED3463D06DE0CA9A15B6153677") else: self.redirect( "/lists?error=02E74F10E0327AD868D138F2B4FDD6F0") else: self.redirect("/lists?error=C20AD4D76FE97759AA27A0C99BFF6710") else: self.redirect("/")
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("/")
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))
def post(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: # First, we remove the content from the user lists for the given movie delete_movies = movielist_mgt.delete_movie_in_lists( user.email(), int(id_movie)) if not delete_movies: self.redirect(route + "?error=9BF31C7FF062936A96D3C8BD1F8F2FF3") # Then, we get the new assignations from form lists_form = self.request.get("list[]", allow_multiple=True) if lists_form: # We built each movie and added it to the correct list for list_id in lists_form: list_select = List.get_by_id(int(list_id)) if not list_select: self.redirect( route + "?error=C74D97B01EAE257E44AA9D5BADE97BAF") movie_to_add_list = movielist_mgt.get_item( user.email(), list_select.key.id(), int(id_movie)) if movie_to_add_list: self.redirect( route + "?error=70EFDF2EC9B086079795C442636B55FB") else: movie_to_add_list = movielist_mgt.create_empty_movie_list( ) movie_to_add_list.user = user.email() movie_to_add_list.id_movie = int(id_movie) movie_to_add_list.id_list = list_select.key.id() if "movies" in route: movie_to_add_list.type_movie = "Movie" else: movie_to_add_list.type_movie = "TV Show" # Chk if len(movie_to_add_list.user) < 1: self.redirect( route + "?error=C4CA4238A0B923820DCC509A6F75849B") if movie_to_add_list.id_movie: self.redirect( route + "?error=C81E728D9D4C2F636F067F89CC14862C") if movie_to_add_list.id_list: self.redirect( route + "?error=37693CFC748049E45D87B8C7D8B9AACD") # Save movielist_mgt.update(movie_to_add_list) self.redirect(route + "?info=1FF1DE774005F8DA13F42943881C655F") else: self.redirect(route + "?info=8E296A067A37563370DED05F5A3BF3EC") else: self.redirect("/")