Beispiel #1
0
def film_add():
    db_session.global_init("db/filmoteka.db")
    db_sess = db_session.create_session()
    form = FilmForm()

    if form.validate_on_submit():
        db_sess = db_session.create_session()
        #film = db_sess.query(Films).filter(Films.id == film_id).first()
        film = Films(
            title=form.title.data,
            year=form.year.data,
            genre=form.genre.data,
            duration=form.duration.data,
            director=form.director.data,
            description=form.description.data
        )

        #print(film.title, film.year, film.genre, film.duration, film.director, film.description)

        db_sess.add(film)
        db_sess.commit()
        flash('Фильм "' + film.title + '" добавлен в каталог')
        return redirect('/catalog')
      

    #film = db_sess.query(Films).filter((Films.id == film_id)).first()
    return render_template("film_add.html", form=form)
Beispiel #2
0
def newfilm():
    form = NewfilmForm()
    if form.validate_on_submit():
        session = db_session.create_session()
        film = Films()
        film.year = form.year.data
        film.name = form.name.data
        film.pict = form.pict.data
        film.trail = form.trail.data
        film.about = form.about.data
        session.add(film)
        session.commit()
        return redirect('/')
    return render_template('newfilm.html',
                           title='Добавление фильма',
                           form=form)
 def post(self):
     parser = reqparse.RequestParser()
     parser.add_argument('title', required=True)
     parser.add_argument('content', required=True)
     parser.add_argument('is_private', required=True, type=bool)
     # parser.add_argument('is_published', required=True, type=bool)
     parser.add_argument('user_id', required=True, type=int)
     args = parser.parse_args()
     session = db_session.create_session()
     news = Films(
         title=args['title'],
         content=args['content'],
         user_id=args['user_id'],
         # is_published=args['is_published'],
         is_private=args['is_private'])
     session.add(news)
     session.commit()
     return jsonify({'success': 'OK'})
Beispiel #4
0
 def post(self, token):
     abort_if_token_not_match(token)
     args = parser.parse_args()
     if errors_if_wrong_data(args) != "":
         return jsonify({"errors": errors_if_wrong_data(args)})
     session = db_session.create_session()
     films = Films(title=args['title'],
                   year=args['year'],
                   country=args['country'],
                   genre=args['genre'],
                   age=args['age'],
                   description=args['description'],
                   show=args['show'],
                   film_url=args['film_url'],
                   photo_url=args['photo_url'],
                   score=args['score'])
     session.add(films)
     session.commit()
     return jsonify({'success': 'OK'})
Beispiel #5
0
def main_main():
    for el in child_adventures_f:
        db_session.global_init("db/list_of_films.sqlite")
        f = Films()
        session = db_session.create_session()
        f.name = el
        f.country = 'foreign'
        f.company = 'child'
        session.add(f)
        # session.commit()
    for el in child_adventures_R:
        db_session.global_init("db/list_of_films.sqlite")
        f = Films()
        session = db_session.create_session()
        f.name = el
        f.country = 'Russia'
        f.company = 'child'
        session.add(f)
        # session.commit()
    for el in anime:
        db_session.global_init("db/list_of_films.sqlite")
        f = Films()
        session = db_session.create_session()
        f.name = el
        f.country = 'foreign'
        f.company = 'child'
        session.add(f)
        # session.commit()
    for el in comedy_R:
        db_session.global_init("db/list_of_films.sqlite")
        f = Films()
        session = db_session.create_session()
        f.name = el
        f.country = 'Russia'
        f.company = 'adult'
        session.add(f)
        # session.commit()
    for el in comedy_f:
        db_session.global_init("db/list_of_films.sqlite")
        f = Films()
        session = db_session.create_session()
        f.name = el
        f.country = 'foreign'
        f.company = 'adult'
        session.add(f)
        # session.commit()
    for el in comedy_child:
        db_session.global_init("db/list_of_films.sqlite")
        f = Films()
        session = db_session.create_session()
        f.name = el
        f.country = 'Russia'
        f.company = 'child'
        session.add(f)
        # session.commit()
    for el in dramma_f:
        db_session.global_init("db/list_of_films.sqlite")
        f = Films()
        session = db_session.create_session()
        f.name = el
        f.country = 'foreign'
        f.company = 'adult'
        session.add(f)
        # session.commit()
    for el in drama_R:
        db_session.global_init("db/list_of_films.sqlite")
        f = Films()
        session = db_session.create_session()
        f.name = el
        f.country = 'Russia'
        f.company = 'adult'
        session.add(f)
        # session.commit()
    for el in sport_f:
        db_session.global_init("db/list_of_films.sqlite")
        f = Films()
        session = db_session.create_session()
        f.name = el
        f.country = 'foreign'
        f.company = 'adult'
        session.add(f)
        # session.commit()
    for el in musikl:
        db_session.global_init("db/list_of_films.sqlite")
        f = Films()
        session = db_session.create_session()
        f.name = el
        f.country = 'Russia'
        f.company = 'adult'
        session.add(f)
        # session.commit()
    for el in historical:
        db_session.global_init("db/list_of_films.sqlite")
        f = Films()
        session = db_session.create_session()
        f.name = el
        f.country = 'Russia'
        f.company = 'adult'
        session.add(f)
        # session.commit()
    for el in biography:
        db_session.global_init("db/list_of_films.sqlite")
        f = Films()
        session = db_session.create_session()
        f.name = el
        f.country = 'foreign'
        f.company = 'child'
        session.add(f)
        # session.commit()
    for el in list_of_genre:
        db_session.global_init("db/list_of_films.sqlite")
        g = Genre()
        session = db_session.create_session()
        g.title_g = el
        session.add(g)
    # session.commit()

    app.run()