Esempio n. 1
0
def create_confirmed():
    file = request.files['source']
    filename = utils.gen_unique_filename(secure_filename(file.filename))
    file.save(os.path.join(constants.CRAWLER_SRC_PATH, filename))

    crawler = Crawler(request.form['name'].strip(), session['account_name'], filename)
    db.session.add(crawler)
    db.session.commit()
    return redirect(url_for('.index'))
Esempio n. 2
0
def create_confirmed():
    book = Book(request.form['name'].strip(), request.form['directory_url'].strip(), request.form['crawler_name'].strip())
    book.description = request.form['description'].strip()
    os.makedirs(os.path.join(constants.BOOK_IMGS_PATH, book.name))
    file = request.files['thumbnail']
    if file:
        filename = utils.gen_unique_filename(secure_filename(file.filename))
        file.save(os.path.join(constants.BOOK_THUMBNAILS_PATH, filename))
        book.thumbnail_filename = filename
    db.session.add(book)
    db.session.commit()
    return redirect(url_for('.index'))
Esempio n. 3
0
def edit_confirmed(name):
    crawler = Crawler.query.filter_by(name=name).first_or_404()
    crawler.author_account = session['account_name']
    file = request.files['source']
    if file:
        filename = utils.gen_unique_filename(secure_filename(file.filename))
        file.save(os.path.join(constants.CRAWLER_SRC_PATH, filename))
        os.remove(os.path.join(constants.CRAWLER_SRC_PATH, crawler.src_filename))
        crawler.src_filename = filename
    crawler.last_modified = datetime.datetime.now()
    crawler.error_message = None
    db.session.commit()
    return redirect(url_for('.index'))
Esempio n. 4
0
def create_confirmed():
    book = Book(request.form['name'].strip(),
                request.form['directory_url'].strip(),
                request.form['crawler_name'].strip())
    book.description = request.form['description'].strip()
    os.makedirs(os.path.join(constants.BOOK_IMGS_PATH, book.name))
    file = request.files['thumbnail']
    if file:
        filename = utils.gen_unique_filename(secure_filename(file.filename))
        file.save(os.path.join(constants.BOOK_THUMBNAILS_PATH, filename))
        book.thumbnail_filename = filename
    db.session.add(book)
    db.session.commit()
    return redirect(url_for('.index'))
Esempio n. 5
0
def edit_confirmed(name):
    book = Book.query.filter_by(name=name).first_or_404()
    book.description = request.form['description'].strip()
    book.directory_url = request.form['directory_url'].strip()
    book.crawler_name = request.form['crawler_name'].strip()
    book.exclude_chapters = request.form['exclude_chapters'].strip()
    file = request.files['thumbnail']
    if file:
        filename = utils.gen_unique_filename(secure_filename(file.filename))
        file.save(os.path.join(constants.BOOK_THUMBNAILS_PATH, filename))
        os.remove(os.path.join(constants.BOOK_THUMBNAILS_PATH, book.thumbnail_filename))
        book.thumbnail_filename = filename
    db.session.commit()
    return redirect(url_for('.index'))
Esempio n. 6
0
def edit_confirmed(name):
    book = Book.query.filter_by(name=name).first_or_404()
    book.description = request.form['description'].strip()
    book.directory_url = request.form['directory_url'].strip()
    book.crawler_name = request.form['crawler_name'].strip()
    book.exclude_chapters = request.form['exclude_chapters'].strip()
    file = request.files['thumbnail']
    if file:
        filename = utils.gen_unique_filename(secure_filename(file.filename))
        file.save(os.path.join(constants.BOOK_THUMBNAILS_PATH, filename))
        os.remove(
            os.path.join(constants.BOOK_THUMBNAILS_PATH,
                         book.thumbnail_filename))
        book.thumbnail_filename = filename
    db.session.commit()
    return redirect(url_for('.index'))