def add_feature(): image = None file = request.files['file'] if file and allowed_file(file.filename): image = secure_filename(file.filename) file.save(os.path.join(app.config['UPLOAD_FOLDER'], image)) title = request.form['title'] release_year = int(request.form['release_year']) country = request.form['country'] director = request.form['director'] main_roles = request.form['main_roles'] genres = request.form['genres'] box_office = int(request.form['box_office']) brief_description = request.form['brief_description'] certificate = request.form['certificate'] runtime = request.form['runtime'] tags = request.form['tags'] trailer = request.form['trailer'] id = str(uuid.uuid4()) feature_film = Feature(id, image, title, release_year, country, director, main_roles, genres, box_office, brief_description, certificate, runtime, tags, trailer) db_feature.add_feature(db_feature.open_db(db_url), feature_film) return redirect(url_for('index_feature'))
def export_csv_feature(): feature_films = db_feature.get_feature_films( db_feature.open_db(db_url)) content = io.StringIO() writer = csv.writer(content) for feature_film in feature_films: writer.writerow([ feature_film.id, feature_film.title, feature_film.release_year, feature_film.country, feature_film.director, feature_film.main_roles, feature_film.genres, feature_film.box_office, feature_film.brief_description, feature_film.certificate, feature_film.runtime, feature_film.tags, feature_film.trailer ]) response = make_response(content.getvalue()) response.headers['Content-Type'] = 'application/octet-stream' response.headers[ 'Content-Disposition'] = 'inline; filename=exported_feature.csv' return response
def index_feature(): feature_films = db_feature.get_feature_films( db_feature.open_db(db_url)) return render_template('index_feature.html', feature_films=feature_films)
def remove_feature(id): db_feature.remove_feature(db_feature.open_db(db_url), id) return redirect(url_for('index'))
def remove_feature_form(id): feature_film = db_feature.get_feature_by_id(db_feature.open_db(db_url), id) return render_template('remove_feature.html', feature_film=feature_film)
def details_feature_by_id(id): feature_film = db_feature.get_feature_by_id(db_feature.open_db(db_url), id) return render_template('details_feature.html', feature_film=feature_film)