예제 #1
0
 def get_movie(self, node) -> Movie:
     """
     Returns a Movie object with all the data found in the bs4 node
     :param node: A soup object positioned in the movie root
     :return: The Movie object
     """
     # Get the link for the movie and generate a soup for this movie subpage
     # This is required because synopsis and duration are obtained from the subpage
     subpage = self.get_movie_soup(self.get_link(node))
     # Create a Movie object and return it on the fly getting each argument from it's own method
     return Movie(title=self.get_title(node), director=self.get_director(node), section=self.get_section(node),
                  synopse=self.get_synopsis(subpage), duration=self.get_duration(subpage))
 def get(self, user):
     templ_vars = { 'user':user }
     url_ending = url_last_part(self.request.url)
     if (url_ending.isdigit()):
         collection = MovieCollection.get_by_id(int(url_ending))
         if collection:
             movies = Movie.get(collection.movies)
             assert not None in movies
             i = 0
             collection.movies = list()
             for key in movies:
                 collection.movies[i] = movies[i]
                 i = i + 1
         templ_vars['collection'] = collection
         return self.render_template('collection.html', templ_vars)
     
     return self.render_template('my_collections.html', templ_vars)
예제 #3
0
 def get(self):
   arg_method = self.request.get('method')
   user = get_current_user()
   if user:
       grab_collections(user)
   
   templ_vars = { 'user':user }
   if not arg_method:
     return self.response.out.write(render_template('root.html', templ_vars))
   
   if arg_method == 'delete':
     arg_what = self.request.get('what')
     if not arg_what:
       return self.request.out.write('no what specified.')
     
     if arg_what == 'users':
       all_users = User.all()
       for user in all_users:
         user.delete()
       return self.redirect('/')
       
     if arg_what == 'collections':
       all_colls = MovieCollection.all()
       for col in all_colls:
         col.delete()
       return self.redirect('/')
     
     if arg_what == 'movies':
       movies = Movie.all()
       for movie in movies:
         movie.delete()
       return self.redirect('/')
     
     if arg_what == 'user_session':
         get_current_session().terminate()
         return self.redirect('/')
     return self.response.out.write(' no valid what')
   
   return self.response.out.write(' no valid method')