예제 #1
0
def init():
    config_name = _Config(current_app.config['CONFIG_FILE'])
    config = _Config(current_app.config['CONFIG_FOLDER'] + '/config_' + config_name.cfg['PROFILE']['id'] + '.ini')
    log = _Log(config.cfg['GLOBAL']['logfile'])
    db_type = config.cfg['DATABASE']['databasetype']
    db = _Database(log, db_type, conn=get_db().conn)
    xml = _Xml(config, db)
    file_name = config.cfg['GLOBAL']['tmppath'] + 'tmp'
    locale = _Locale(config)
    files = _Files(
        file_name,
        int(config.cfg['GLOBAL']['resolution']),
        int(config.cfg['GLOBAL']['compressionquality']),
        xml,
        log,
        config.cfg['GLOBAL']['convertpdftotiff'],
        locale,
        config
    )
    ocr = _PyTesseract(locale.localeOCR, log, config)
    splitter = _Splitter(config, db, locale)
    ws = ''

    if config.cfg['GED']['enabled'] == 'True':
        ws = _WebServices(
            config.cfg['GED']['host'],
            config.cfg['GED']['user'],
            config.cfg['GED']['password'],
            log,
            config
        )

    return db, config, locale, ws, xml, files, ocr, splitter
예제 #2
0
def register():
    if request.method == 'POST':
        username = request.form['username']
        password = request.form['password']
        db = get_db()
        error = None
        user = db.select({
            'select': ['id'],
            'table': ['users'],
            'where': ['username = ?'],
            'data': [username]
        })

        if not username:
            error = gettext('USERNAME_REQUIRED')
        elif not password:
            error = gettext('PASSWORD_REQUIRED')
        elif user:
            error = gettext('USER') + ' ' + username + ' ' + gettext(
                'ALREADY_REGISTERED')

        if error is None:
            db.insert({
                'table': 'users',
                'columns': {
                    'username': username,
                    'password': generate_password_hash(password)
                }
            })
            flash(gettext('USER_CREATED_OK'))
            return redirect(url_for('auth.login'))
        flash(error)

    return render_template('templates/auth/register.html')
예제 #3
0
def init():
    configName = _Config(current_app.config['CONFIG_FILE'])
    Config = _Config(current_app.config['CONFIG_FOLDER'] + '/config_' +
                     configName.cfg['PROFILE']['id'] + '.ini')
    Log = _Log(Config.cfg['GLOBAL']['logfile'])
    db = _Database(Log, None, get_db())
    Locale = _Locale(Config)
    configFile = current_app.config[
        'CONFIG_FOLDER'] + '/config_' + configName.cfg['PROFILE']['id'] + '.ini'

    return db, Config, Locale, configName, configFile
예제 #4
0
def load_logged_in_user():
    user_id = session.get('user_id')

    if user_id is None:
        g.user = None
    else:
        db = get_db()
        g.user = db.select({
            'select': ['*'],
            'table': ['users'],
            'where': ['id = ?'],
            'data': [user_id]
        })[0]
예제 #5
0
def login(fallback):
    if fallback is not None:
        fallback = fallback.replace('%', '/')
    else:
        fallback = url_for('pdf.index', time='TODAY')

    if request.method == 'POST':
        username = request.form['username']
        password = request.form['password']
        db = get_db()
        error = None
        user = db.select({
            'select': ['*'],
            'table': ['users'],
            'where': ['username = ?'],
            'data': [username]
        })

        if not user:
            error = gettext('USERNAME_REQUIRED')
        elif not check_password_hash(user[0]['password'], password):
            error = gettext('PASSWORD_REQUIRED')
        elif user[0]['status'] == 'DEL':
            error = gettext('USER_DELETED')
        elif user[0]['enabled'] == 0:
            error = gettext('USER_DISABLED')

        if error is None:
            lang = session['lang']
            session.clear()
            session['user_id'] = user[0]['id']
            session['user_name'] = user[0]['username']
            session['lang'] = lang

            return redirect(fallback)

        flash(error)

    return render_template('templates/auth/login.html')
예제 #6
0
def init():
    configName = _Config(current_app.config['CONFIG_FILE'])
    Cfg = _Config(current_app.config['CONFIG_FOLDER'] + '/config_' +
                  configName.cfg['PROFILE']['id'] + '.ini')
    Log = _Log(Cfg.cfg['GLOBAL']['logfile'])
    dbType = Cfg.cfg['DATABASE']['databasetype']
    db = _Database(Log, dbType, conn=get_db().conn)
    Xml = _Xml(Cfg, db)
    fileName = Cfg.cfg['GLOBAL']['tmppath'] + 'tmp'
    Files = _Files(fileName, int(Cfg.cfg['GLOBAL']['resolution']),
                   int(Cfg.cfg['GLOBAL']['compressionquality']), Xml, Log,
                   Cfg.cfg['GLOBAL']['convertpdftotiff'])
    Locale = _Locale(Cfg)
    Ocr = _PyTesseract(Locale.localeOCR, Log, Cfg)
    splitter = _Splitter(Cfg, db, Locale)
    ws = ''

    if Cfg.cfg['GED']['enabled'] == 'True':
        ws = _WebServices(Cfg.cfg['GED']['host'], Cfg.cfg['GED']['user'],
                          Cfg.cfg['GED']['password'], Log, Cfg)

    return db, Cfg, Locale, ws, Xml, Files, Ocr, splitter