Ejemplo n.º 1
0
def add_film():
    if request.method == 'POST':
        name = request.form['name1']
        description = request.form['description']
        genre = request.form['genre']
        producer = request.form['producer']
        year = request.form['year']
        country = request.form['country']
        length = request.form['length']
        cast = request.form['cast']
        ageRestriction = request.form['ageRestriction']
        if 'file' not in request.files:
            flash('Нету файла')
            return redirect(url_for('add_film'))
        file = request.files['file']
        if file.filename == '':
            flash('Файл не выбран')
            return redirect(request.url)
        if file:
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
            foto = os.path.join(app.config['UPLOAD_FOLDER'], filename)
            index = str(foto).find("static")
            pathPhoto = str(foto[index:])
            movie = Film(name, description, cast, genre, producer, year,
                         country, length, ageRestriction, pathPhoto)
            db.session.add(movie)
            db.session.commit()
            return redirect(url_for("session_cinema"))
    return render_template('addfilms.html')
Ejemplo n.º 2
0
def delete_rate(film_id):
    film = Film()
    user = User()
    if not film.check_film(film_id):
        return render_template("404.html")
    if user.check_rate(film_id):
        val = user.delete_rate(film_id)
        film.delete_rate(film_id, val)
    return redirect(url_for('movie', film_id=film_id))
Ejemplo n.º 3
0
def rate_movie(film_id, val):
    film = Film()
    user = User()
    if not film.check_film(film_id):
        return render_template("404.html")
    if not user.check_rate(film_id):
        user.rate(film_id, val)
        film.rate(film_id, val)
    return redirect(url_for('movie', film_id=film_id))
Ejemplo n.º 4
0
def favorite(film_id):
    db_f = Film()
    if not db_f.check_film(film_id):
        return render_template('404.html')
    db = Favorites()
    user_id = db.current_user(session['__auth'])
    if not db.check_duplicate(user_id, film_id):
        db.add_favorites(user_id, film_id)
    return redirect(url_for('movie', film_id=film_id))
Ejemplo n.º 5
0
def write_review(film_id):
    form = ReviewForm()
    if not form.validate_on_submit():
        return redirect(url_for('movie', film_id=film_id))
    film = Film()
    user = User()
    body = form.review.data
    user_id = user.current_user(session['__auth'])
    film.write_review(body=body, user_id=user_id, film_id=film_id)
    return redirect(url_for('movie', film_id=film_id))
Ejemplo n.º 6
0
	def save(self, form):
		name = form.name.data
		studio = form.studio.data
		year = form.year.data
		duration = form.duration.data
		genre = form.genre.data
		nom_count = form.nom_count.data
		if self.new:
			Film().insert(name, studio, year, duration, genre, nom_count, fact_count=nom_count)
		else:	self.data.update(name, studio, year, duration, genre, nom_count, fact_count=self.data.fact_count)
		return True
Ejemplo n.º 7
0
 def test_film_model_4(self):
     data = filmdata
     d = data['1']
     d2 = data['2']
     id = 1
     id2 = 2
     film = Film(
         id, d['title'], d['director'], d['producer'], d['episode_id'],
         d['release_date'],
         "http://cdn2us.denofgeek.com/sites/denofgeekus/files/starwars-iv.jpg"
     )
     film2 = Film(
         id2, d2['title'], d2['director'], d2['producer'], d2['episode_id'],
         d2['release_date'],
         "http://cdn2us.denofgeek.com/sites/denofgeekus/files/starwars-iv.jpg"
     )
     test_db.session.add(film)
     test_db.session.add(film2)
     s = test_db.session.query(Film).get(str(2))
     director = s.director
     self.assertEqual(d2['director'], director)
     test_db.session.delete(film)
     test_db.session.delete(film2)
     test_db.session.commit()
Ejemplo n.º 8
0
 def test_film_model_1(self):
     """Test querying the database by attribute using simple keywords"""
     data = filmdata
     d = data['1']
     id = 1
     film = Film(
         id, d['title'], d['director'], d['producer'], d['episode_id'],
         d['release_date'],
         "http://cdn2us.denofgeek.com/sites/denofgeekus/files/starwars-iv.jpg"
     )
     test_db.session.add(film)
     s = test_db.session.query(Film).all()
     count = len(s)
     self.assertEqual(1, count)
     test_db.session.delete(film)
     test_db.session.commit()
Ejemplo n.º 9
0
def populate_films():
	#This will put data in the film table of the db
	data = [
(1, u'The Greatest Showman', u'American musical drama film, written by Jenny Bicks and starring Hugh Jackman, Zac Efront, Michelle Williams, Rebecca Ferguson and Zendaya', 120, u'Michael Gracey', u'12',u'showman2.jpg'),
(2, u'Black Panther', u'With the King of Wakanda now dead, his son T’Challa must return home to take his rightful place on the throne. But, it’s going to be a bumpy ride, as an evil faction has other plans for the country’s future. | Actors: Chadwick Boseman, Michael B. Jordan, Lupita Nyongo |', 134, u'Ryan Coogler', u'12',u'BlackPanther.jpg'),
(3, u'Coco', u'Ignoring his family’s baffling ban on music, Miguel embarks on a journey through the enchanting Land of the Dead in search of his dreams of becoming a musician. | Actors:  Anthony Gonzalez, Gael García Bernal, Benjamin Bratt |', 105, u'Adrian Molina', u'U',u'cocoKids.jpg'),
(4, u'Downsizing', u'A married couple decide to escape the daily humdrum of modern life by downsizing – a procedure which will see their bodies shrink to 5 inches tall, but their modest savings turn into millions of pounds. | Actors: Matt Damon, Christoph Waltz, Hong Chau |', 135, u'Alexander Payne', u'15',u'downsizingTeen.jpg'),
(5, u'Early Man', u'As the Bronze Age arrives and the Stone Age is over, a determined caveman and his faithful sidekick must fight for his home and the rights of his people. | Actors:  Tom Hiddleston, Eddie Redmayne, Maisie Williams |', 89, u'Nick Park', u'U',u'earlymanKids.jpg'),
(6, u'Jumanji: Welcome To The Jungle', u'When four kids dust off an old video game and begin to play ‘Jumanji’, they quickly realise this is not a normal game. It’s a game of survival, where only the winners return to the real world. | Actors: Dwayne Johnson, Karen Gillan, Kevin Hart |', 119, u'Jake Kasdan', u'12',u'jumanji.jpg'),
(7, u'Darkest Hour', u'The fate of Britain lies on Winston Churchill’s shoulders, in this historical-drama that tells the story of the country’s darkest – and strongest – hours. | Actors: Gary Oldman, Lily James, Kristin Scott Thomas | ', 125, u'Joe Wright', u'U',u'darkestHour.jpg'),
(8, u'The Post', u'In June 1971 The New York Times, the Washington Post and the nations major newspapers took a brave stand for freedom of speech and reported on the Pentagon Papers, the massive cover-up of government secrets that spanned four decades and four Presidents. | Actors: Meryl Streep, Tom Hanks, Sarah Paulson |', 116, u'Steven Spielberg', u'12',u'thepostSenior.jpg'),
(9, u'Maze Runner: The Death Cure', u'The final battle: Thomas must try to find a cure for the disease that has destroyed most of society. Live or die: everything is about to change... |Actors: Dylan O Brien, Ki Hong Lee, Kaya Scodelario |', 142, u'Wes Ball', u'12',u'mazerunnerTeen.jpg'),
(10, u'Journeys End', u'With Operation Michael in full swing and a battle on the horizon, a group of British soldiers holed up in a dugout in Aisne in 1918 anxiously await their fate. | Actors:  Sam Claflin, Paul Bettany, Asa Butterfield |', 107, u'Saul Dibb', u'12',u'journeysend.jpg')
]
	for d in data:
		film = Film(film_id=d[0],film_name=d[1],film_description=d[2],film_runtime=d[3], film_director=d[4], film_age_rating=d[5],film_poster=d[6])
		db.session.add(film)
	db.session.commit()
Ejemplo n.º 10
0
def add_film(film):
    if film['remouteImage'] == '':
        film[
            'remouteImage'] = 'https://lh3.googleusercontent.com/proxy/5Bk8ufycEoJ8QueSE7l_cPLwH5B7m5aRf1wFTEg-Ij1AvwDYDkHXwoNEFlJox8_XBBOHEgsetfnUt6AF1j31pAVk'
    if film['image'] == '':
        film[
            'image'] = 'https://lh3.googleusercontent.com/proxy/5Bk8ufycEoJ8QueSE7l_cPLwH5B7m5aRf1wFTEg-Ij1AvwDYDkHXwoNEFlJox8_XBBOHEgsetfnUt6AF1j31pAVk'
    if film['trailer'] == '':
        film[
            'trailer'] = 'https://lh3.googleusercontent.com/proxy/5Bk8ufycEoJ8QueSE7l_cPLwH5B7m5aRf1wFTEg-Ij1AvwDYDkHXwoNEFlJox8_XBBOHEgsetfnUt6AF1j31pAVk'
    if film['description'] == '':
        film['description'] = 'some description'
    film = Film(name=film['name'],
                image=film['image'],
                description=film['description'],
                type=film['type'],
                trailer=film['trailer'],
                remouteImage=film['remouteImage'])
    db.session.add(film)
    db.session.commit()
Ejemplo n.º 11
0
def addfilm():
    form = AddFilmForm()
    if form.validate_on_submit():
        exists = db.session.query(Film).filter_by(title=form.title.data,
                                                  year=form.year.data).first()
        if exists is not None:
            flash('Film already in database')
        else:
            film = Film(title=form.title.data,
                        year=form.year.data,
                        genre=form.genre.data,
                        platform=form.platform.data,
                        summary=form.summary.data,
                        image_url=form.image_url.data,
                        watched=False)
            db.session.add(film)
            db.session.commit()
            flash('Film \'{}\', {} added successfully'.format(
                form.title.data, form.year.data))
        return redirect(url_for('addfilm'))
    return render_template('addfilm.html', title='Add Film', form=form)
Ejemplo n.º 12
0
def movie(film_id):
    form = ReviewForm()
    db = Film()
    db_w = Watchlist()
    db_user = User()
    page = request.args.get('page', '1')
    if not db.check_film(film_id):
        return render_template('404.html')
    (film, directors, actors, genres,
     reviews, page, pageCount) = db.get_film(film_id, page)
    if session.get("__auth"):
        list_names = db_w.watchlist_names(session["__auth"])
        rate = db_user.check_rate(film_id)
    else:
        list_names = []
        rate = 0
    return render_template('movie.html', form=form, film=film,
                           directors=directors, actors=actors,
                           genres=genres, reviews=reviews,
                           list_names=list_names, rate=rate,
                           page=page, pageCount=pageCount)
Ejemplo n.º 13
0
def boxoffice():
    db = Film()
    films = db.highest_grossing_movies()
    return render_template('boxoffice.html', films=films)
Ejemplo n.º 14
0
def top_rated():
    db = Film()
    films = db.get_top_movies()
    return render_template('top.html', films=films)
Ejemplo n.º 15
0
	def find(self, film_id):
		return Film().find(film_id)
Ejemplo n.º 16
0
	def __init__(self, id=None):
		if id is not None:
			self.data = Film().find(id)
			self.new = False
		else:	self.new = True
Ejemplo n.º 17
0
def popular():
    db = Film()
    films = db.get_popular_movies()
    return render_template('popular.html', films=films)