Example #1
0
def main():
    view = View()
    print("------------No movies added---------------")
    view.show_all()
    print("------------Adding 1st movie-------------")
    movie_to_add = Movie(title="The Imitation Game",
                         date_released=2014,
                         actors=[
                             Actor(first_name="Benedict",
                                   last_name="Cumberbatch",
                                   role="Alan Turing"),
                             Actor(first_name="Keira",
                                   last_name="Knightley",
                                   role="Joan Clarke")
                         ])
    view.add_movie(movie_obj=movie_to_add)
    view.show_all()
    print("------------Adding 2nd movie-------------")
    movie_to_add = Movie(title="A Beautiful Mind",
                         date_released=2001,
                         actors=[
                             Actor(first_name="Russell",
                                   last_name="Crowe",
                                   role="John Nash"),
                             Actor(first_name="Ed",
                                   last_name="Harris",
                                   role="William Parcher"),
                             Actor(first_name="Jennifer",
                                   last_name="Connelly",
                                   role="Alicia Nash")
                         ])
    view.add_movie(movie_obj=movie_to_add)
    view.show_all()
Example #2
0
def deploy():
    db.drop_all()
    db.create_all()
    actor1 = Actor(name='Robert Downey Jr.', age='52', gender='Male')
    actor2 = Actor(name='Scarlett Johansson', age='33', gender='Female')
    actor3 = Actor(name='Christian Bale', age='43', gender='Male')
    movie1 = Movie(title='Iron Man',
                   year="2008",
                   description="Man made of iron",
                   actor=actor1)
    movie2 = Movie(title='The Avengers',
                   year="2012",
                   description="Avengers save the world",
                   actor=actor2)
    movie3 = Movie(title='The Dark Knight',
                   year="2008",
                   description="Batman vs Joker",
                   actor=actor3)
    db.session.add(actor1)
    db.session.add(actor2)
    db.session.add(actor3)
    db.session.add(movie1)
    db.session.add(movie2)
    db.session.add(movie3)
    db.session.commit()
Example #3
0
def main():
    view = View()
    print("Here are empty list of movies")
    view.show_all()
    print("Please add the first movie")
    movie_to_add = Movie(
        title="The Imitation Game",
        date_released=2014,
        actors=[
            Actor(name="Benedict", last_name="Cumberbatch", role="Alan Turing"),
            Actor(name="Kira", last_name="Knightley", role="Joan Clarke")
        ]
    )
    view.add_movie(movie_obj=movie_to_add)
    view.show_all()

    movie_to_add_two = Movie(
        title="Solaris",
        date_released=1972,
        actors=[
            Actor(name="Donatas", last_name="Banionis",
                  role="Kris Kelvin"),
            Actor(name="Natalya", last_name="Bondarchuk",
                  role="Hari")
        ]
    )
    view.add_movie(movie_obj=movie_to_add_two)
    view.show_all()
def main():
    view = View()
    view.show_all()
    actors = [
        Actor(name="Peter", last_name="First", role="main_Hero"),
        Actor(name="Kira", last_name="Knightley", role="Joan Clarke"),
        Actor(name="Benedict", last_name="Cumberbatch", role="Alan Turing")
    ]
    movie_obj = Movie(title="Firs Peter", date_realized=2020, actor=actors)
    view.add_movie(movie_obj=movie_obj)
    view.dump()
Example #5
0
def deploy():
    db.drop_all()
    db.create_all()
    actor1 = Actor(name='Coldplay', active='1999-present')
    actor2 = Actor(name='Maroon 5', active='2010-2017')
    movie1 = Movie(title='Yellow', year=2000, actor=actor1)
    movie2 = Movie(title='Suger', year=2014, actor=actor2)
    db.session.add(actor1)
    db.session.add(actor2)
    db.session.add(movie1)
    db.session.add(movie2)
    db.session.commit()
Example #6
0
def main():
    view = View()
    view.show_all()
    movie_to_add = Movie(title="The Imitation Game",
                         date_released=2014,
                         actors=[
                             Actor(name="Benedict",
                                   last_name="Cumberbatch",
                                   role="Alan Turing"),
                             Actor(name="Kira",
                                   last_name="Knightley",
                                   role="Joan Clarke")
                         ])
    view.add_movie(movie_obj=movie_to_add)
    view.show_all()
Example #7
0
 def load_all(self):
     with open(self._dump_filename, "rt") as f:
         movies_serialized = json.load(f)
         for movie_dict in movies_serialized:
             actors = [Actor(**actor) for actor in movie_dict["actors"]]
             movie = Movie(movie_dict["title"], movie_dict["release_date"],
                           actors)
             self._all_movies.append(movie)
Example #8
0
def deploy():
    print("resetting database....")
    db.drop_all()
    db.create_all()

    gosling = Actor(name="Ryan Gosling", age="37")
    evans = Actor(name="Chris Evans", age="36")
    lawrence = Actor(name="Jennifer Lawrence", age="27")

    notebook = Movie(
        title="The Notebook",
        year="2004",
        description=
        "This movie is incredibly romantic. I would reccomend seeing this with a loved one, or if its a girls night and you want to cry. This is such a beautiful movie!",
        actor=gosling)
    avengers = Movie(
        title="The Avengers",
        year="2012",
        description=
        "The Avengers is the best superhero movie ever made so far. Different superheros come together to fight in an awesome squad to beat aliens and villians.",
        actor=evans)
    sparrow = Movie(
        title="Red Sparrow",
        year="2018",
        description=
        "The Red Sparrow is definitely not your average movie, it is action packed, bloody and sexual all at the same time.",
        actor=lawrence)

    db.session.add(gosling)
    db.session.add(evans)
    db.session.add(lawrence)

    db.session.add(notebook)
    db.session.add(avengers)
    db.session.add(sparrow)

    db.session.commit()
Example #9
0
 def load(self):
     json_movies = []
     self.all_movies = []
     file_exists = path.isfile(self._dump_filename)
     if file_exists:
         with open(self._dump_filename) as file:
             for line in file:
                 movie_dict = json.loads(line)
                 json_movies.append(movie_dict)
         for movie in json_movies:
             actors = []
             for actor in movie["_actors"]:
                 actors.append(
                     Actor(first_name=actor["_first_name"],
                           last_name=actor["_last_name"],
                           role=actor["_role"]))
             self.all_movies.append(
                 Movie(title=movie["_title"],
                       date_released=movie["_date_released"],
                       actors=actors))
     return self.all_movies
Example #10
0
                for mov in str_obj:
                    self._list_movie.append(
                        Movie.make_obj(dict_serilization=mov))
                return self._list_movie
        except (FileNotFoundError, TypeError):
            f = open(self._dump_filename, "wt")
            f.close()

    def get_all_movie(self):
        if not self._list_movie:
            return ("Список пуст", )
        return self._list_movie

    def show_all(self):
        movies = self.get_all_movie()
        for movie in movies:
            print(movie)
        return movies


if __name__ == '__main__':
    mod = Model()
    actors = [
        Actor(name="Peter", last_name="First", role="main_Hero"),
        Actor(name="Kira", last_name="Knightley", role="Joan Clarke"),
        Actor(name="Benedict", last_name="Cumberbatch", role="Alan Turing")
    ]
    movie_obj = Movie(title="Firs Peter", date_realized=2020, actor=actors)
    mod.add_movie(movie_obj=movie_obj)
    mod.show_all()
Example #11
0
from movie import Actor, Movie
from movie.controller import Conector


class View:
    def __init__(self):
        self.conector = Conector()

    def add_movie(self, movie_obj):
        self.conector.add_movie(movie_obj)

    def show_all(self):
        movies = self.conector.show_all()
        for movie in movies:
            print(movie)

    def dump(self):
        self.conector.dump()


if __name__ == '__main__':
    view = View()
    peter = [Actor(name="Peter", last_name="First", role="main")]
    movie_obj = Movie(title="Firs Peter", date_realized=2020, actor=peter)