Example #1
0
 def export_csv_documentary():
     documentary_films = db_documentary.get_documentary_films(
         db_documentary.open_db(db_url))
     content = io.StringIO()
     writer = csv.writer(content)
     for documentary_film in documentary_films:
         writer.writerow([
             documentary_film.id, documentary_film.title,
             documentary_film.release_year, documentary_film.country,
             documentary_film.director, documentary_film.category,
             documentary_film.brief_description,
             documentary_film.certificate, documentary_film.runtime,
             documentary_film.tags, documentary_film.trailer
         ])
     response = make_response(content.getvalue())
     response.headers['Content-Type'] = 'application/octet-stream'
     response.headers[
         'Content-Disposition'] = 'inline; filename=exported_documentary.csv'
     return response
Example #2
0
 def edit_documentary(id):
     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']
     category = request.form['category']
     brief_description = request.form['brief_description']
     certificate = request.form['certificate']
     runtime = request.form['runtime']
     tags = request.form['tags']
     trailer = request.form['trailer']
     documentary_film = Documentary(id, image, title, release_year, country,
                                    director, category, brief_description,
                                    certificate, runtime, tags, trailer)
     db_documentary.update_documentary(db_documentary.open_db(db_url),
                                       documentary_film)
     return redirect(url_for('details_documentary_by_id', id=id))
Example #3
0
 def index_documentary():
     documentary_films = db_documentary.get_documentary_films(
         db_documentary.open_db(db_url))
     return render_template('index_documentary.html',
                            documentary_films=documentary_films)
Example #4
0
 def remove_documentary(id):
     db_documentary.remove_documentary(db_documentary.open_db(db_url), id)
     return redirect(url_for('index'))
Example #5
0
 def remove_documentary_form(id):
     documentary_film = db_documentary.get_documentary_by_id(
         db_documentary.open_db(db_url), id)
     return render_template('remove_documentary.html',
                            documentary_film=documentary_film)
Example #6
0
 def details_documentary_by_id(id):
     documentary_film = db_documentary.get_documentary_by_id(
         db_documentary.open_db(db_url), id)
     return render_template('details_documentary.html',
                            documentary_film=documentary_film)