How to use the docassemble.base.config.daconfig.get function in docassemble

To help you get started, we’ve selected a few docassemble examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jhpyle / docassemble / docassemble_webapp / docassemble / webapp / wsgi_restart.py View on Github external
def main():
    from docassemble.base.config import daconfig
    webapp_path = daconfig.get('webapp', '/usr/share/docassemble/webapp/docassemble.wsgi')
    wsgi_file = webapp_path
    if os.path.isfile(wsgi_file):
        with open(wsgi_file, 'a'):
            os.utime(wsgi_file, None)
            sys.stderr.write("Restarted WSGI.\n")
    sys.exit(0)
github jhpyle / docassemble / docassemble_base / docassemble / base / standardformatter.py View on Github external
from docassemble.base.functions import word, currency_symbol, url_action, comma_and_list, server
from docassemble.base.filter import markdown_to_html, get_audio_urls, get_video_urls, audio_control, video_control, noquote, to_text, my_escape
from docassemble.base.parse import Question, debug
from docassemble.base.logger import logmessage
from docassemble.base.config import daconfig
import urllib
import sys
import os
import re
import json
import random
import sys
import codecs

DECORATION_SIZE = daconfig.get('decoration size', 2.0)
DECORATION_UNITS = daconfig.get('decoration units', 'em')
BUTTON_ICON_SIZE = daconfig.get('button icon size', 4.0)
BUTTON_ICON_UNITS = daconfig.get('button icon units', 'em')
if daconfig.get('button size', 'large') == 'large':
    BUTTON_CLASS = 'btn-lg btn-da'
else:
    BUTTON_CLASS = 'btn-da'

def tracker_tag(status):
    output = ''
    output += '                <input value="' + server.generate_csrf() + '" name="csrf_token" type="hidden">\n'
    if len(status.next_action):
        output += '                <input value=" + myb64doublequote(json.dumps(status.next_action)) + " name="_next_action" type="hidden">\n'
    if status.question.name:
        output += '                <input value="' + status.question.name + '" name="_question_name" type="hidden">\n'
    # if 'orig_action' in status.current_info:
    #     output += '                <input value=" + myb64doublequote(json.dumps(dict(action=status.current_info[" name="_action_context" type="hidden">\n'
github jhpyle / docassemble / docassemble_webapp / docassemble / webapp / socketserver.py View on Github external
import netifaces as ni
                ifaces = [iface for iface in ni.interfaces() if iface != 'lo']
                host = ni.ifaddresses(ifaces[0])[ni.AF_INET][0]['addr']
            socketio.run(app, host=host, port=daconfig.get('websockets port', 5000))
        except:
            sys.stderr.write("Could not find the external IP address\n")
            if 'websockets ip' in daconfig and daconfig['websockets ip']:
                socketio.run(app, host=daconfig['websockets ip'], port=daconfig.get('websockets port', 5000))
            elif 'websockets port' in daconfig and daconfig['websockets port']:
                socketio.run(app, port=daconfig['websockets port'])
            else:
                socketio.run(app)
    else:
        sys.stderr.write("6\n")
        if 'websockets ip' in daconfig and daconfig['websockets ip']:
            socketio.run(app, host=daconfig['websockets ip'], port=daconfig.get('websockets port', daconfig.get('websockets port', 5000)))
        elif 'websockets port' in daconfig and daconfig['websockets port']:
            socketio.run(app, port=daconfig['websockets port'])
        else:
            socketio.run(app)
github jhpyle / docassemble / docassemble_webapp / docassemble / webapp / setup.py View on Github external
app.config['DA_VERSION'] = da_version
app.config['APP_NAME'] = daconfig.get('appname', 'docassemble')
app.config['BRAND_NAME'] = daconfig.get('brandname', daconfig.get('appname', 'docassemble'))
app.config['SHOW_PROFILE'] = True if daconfig.get('show profile link', True) else False
app.config['SHOW_MY_INTERVIEWS'] = True if daconfig.get('show interviews link', True) else False
app.config['SHOW_DISPATCH'] = True if len(daconfig['dispatch']) and daconfig.get('show dispatch link', False) else False
app.config['MAIL_USERNAME'] = daconfig['mail'].get('username', None)
app.config['MAIL_PASSWORD'] = daconfig['mail'].get('password', None)
app.config['MAIL_DEFAULT_SENDER'] = daconfig['mail'].get('default sender', None)
app.config['MAIL_SERVER'] = daconfig['mail'].get('server', 'localhost')
app.config['MAIL_PORT'] = daconfig['mail'].get('port', 25)
app.config['MAIL_USE_SSL'] = daconfig['mail'].get('use ssl', False)
app.config['MAIL_USE_TLS'] = daconfig['mail'].get('use tls', True)
#app.config['ADMINS'] = [daconfig.get('admin address', None)]
app.config['APP_SYSTEM_ERROR_SUBJECT_LINE'] = app.config['APP_NAME'] + " system error"
app.config['APPLICATION_ROOT'] = daconfig.get('root', '/')
app.config['CSRF_ENABLED'] = False
if daconfig['two factor authentication'].get('enable', True):
    app.config['USE_MFA'] = True
else:
    app.config['USE_MFA'] = False
if daconfig['two factor authentication'].get('allow sms', True):
    app.config['MFA_ALLOW_SMS'] = True
else:
    app.config['MFA_ALLOW_SMS'] = False
if daconfig['two factor authentication'].get('allow app', True):
    app.config['MFA_ALLOW_APP'] = True
else:
    app.config['MFA_ALLOW_APP'] = False
if 'required for' in daconfig['two factor authentication'] and isinstance(daconfig['two factor authentication']['required for'], list):
    app.config['MFA_REQUIRED_FOR_ROLE'] = daconfig['two factor authentication']['required for']
else:
github jhpyle / docassemble / docassemble_webapp / docassemble / webapp / create_tables.py View on Github external
def populate_tables():
    user_manager = UserManager(SQLAlchemyAdapter(db, UserModel, UserAuthClass=UserAuthModel), app)
    admin_defaults = daconfig.get('default admin account', dict())
    if 'email' not in admin_defaults:
        admin_defaults['email'] = os.getenv('DA_ADMIN_EMAIL', 'admin@admin.com')
    if 'nickname' not in admin_defaults:
        admin_defaults['nickname'] = 'admin'
    if 'first_name' not in admin_defaults:
        admin_defaults['first_name'] = word('System')
    if 'last_name' not in admin_defaults:
        admin_defaults['last_name'] = word('Administrator')
    if 'password' not in admin_defaults:
        admin_defaults['password'] = os.getenv('DA_ADMIN_PASSWORD', 'password')
    cron_defaults = daconfig.get('default cron account', {'nickname': 'cron', 'email': 'cron@admin.com', 'first_name': 'Cron', 'last_name': 'User'})
    cron_defaults['active'] = False
    user_role = get_role(db, 'user')
    admin_role = get_role(db, 'admin')
    cron_role = get_role(db, 'cron')
    customer_role = get_role(db, 'customer')
github jhpyle / docassemble / docassemble_webapp / docassemble / webapp / fix_postgresql_tables.py View on Github external
def main():
    dbconfig = daconfig.get('db', dict())
    db_prefix = dbconfig.get('prefix', 'postgresql+psycopg2://')
    if db_prefix != 'postgresql+psycopg2://':
        sys.stderr.write("fix_postgresql_tables: skipping because configured database is not PostgreSQL.\n")
        return
    db_name = dbconfig.get('name', None)
    db_host = dbconfig.get('host', None)
    db_user = dbconfig.get('user', None)
    db_password = dbconfig.get('password', None)
    db_port = dbconfig.get('port', None)
    db_table_prefix = dbconfig.get('table prefix', None)
    schema_file = dbconfig.get('schema file', None)
    if db_name is None:
        db_name = os.getenv('DBNAME', '')
    if db_name == '':
        db_name = 'docassemble'
    if db_host is None:
github jhpyle / docassemble / docassemble_webapp / docassemble / webapp / setup.py View on Github external
if not (app.config['MFA_ALLOW_SMS'] or app.config['MFA_ALLOW_APP']):
    app.config['USE_MFA'] = False
app.config['API_ROLES'] = daconfig.get('api privileges', ['admin', 'developer'])
app.config['WTF_CSRF_TIME_LIMIT'] = 604800
app.config['WTF_CSRF_SSL_STRICT'] = daconfig.get('require referer', (True if daconfig.get('cross site domains', None) is None else False))
app.config['USER_APP_NAME'] = app.config['APP_NAME']
app.config['USER_SEND_PASSWORD_CHANGED_EMAIL'] = False
app.config['USER_SEND_REGISTERED_EMAIL'] = True if daconfig.get('confirm registration', False) else False
app.config['USER_SEND_USERNAME_CHANGED_EMAIL'] = False
app.config['USER_ENABLE_RETYPE_PASSWORD'] = True if daconfig.get('retype password', True) else False
app.config['USER_ENABLE_REMEMBER_ME'] = False
app.config['USER_ENABLE_EMAIL'] = True
app.config['USER_ENABLE_USERNAME'] = False
app.config['USER_ENABLE_REGISTRATION'] = True
app.config['USER_ENABLE_CHANGE_USERNAME'] = False
app.config['USER_ENABLE_CONFIRM_EMAIL'] = True if daconfig.get('confirm registration', False) else False
app.config['USER_ENABLE_LOGIN_WITHOUT_CONFIRM_EMAIL'] = False if daconfig.get('confirm registration', False) else True
app.config['USER_AUTO_LOGIN_AFTER_REGISTER'] = False if daconfig.get('confirm registration', False) else True
app.config['USER_SHOW_USERNAME_EMAIL_DOES_NOT_EXIST'] = False if daconfig.get('confirm registration', False) else True
app.config['USER_AUTO_LOGIN_AFTER_RESET_PASSWORD'] = False
app.config['USER_AFTER_FORGOT_PASSWORD_ENDPOINT'] = 'user.login'
app.config['USER_AFTER_CHANGE_PASSWORD_ENDPOINT'] = 'after_reset'
app.config['USER_AFTER_CHANGE_USERNAME_ENDPOINT'] = 'user.login'
app.config['USER_INVITE_ENDPOINT'] = 'user_list'
app.config['USER_AFTER_CONFIRM_ENDPOINT'] = 'user.login'
app.config['USER_AFTER_LOGIN_ENDPOINT'] = 'interview_list'
app.config['USER_AFTER_LOGOUT_ENDPOINT'] = 'user.login'
app.config['USER_AFTER_REGISTER_ENDPOINT'] = 'user.login' if daconfig.get('confirm registration', False) else 'interview_list'
app.config['USER_AFTER_RESEND_CONFIRM_EMAIL_ENDPOINT'] = 'user.login'
app.config['USER_AFTER_RESET_PASSWORD_ENDPOINT'] = 'user.login'
app.config['USER_INVITE_URL'] = '/user/invite'
app.config['USER_ENABLE_INVITATION'] = True
github jhpyle / docassemble / docassemble_webapp / docassemble / webapp / setup.py View on Github external
else:
    app.config['MFA_ALLOW_SMS'] = False
if daconfig['two factor authentication'].get('allow app', True):
    app.config['MFA_ALLOW_APP'] = True
else:
    app.config['MFA_ALLOW_APP'] = False
if 'required for' in daconfig['two factor authentication'] and isinstance(daconfig['two factor authentication']['required for'], list):
    app.config['MFA_REQUIRED_FOR_ROLE'] = daconfig['two factor authentication']['required for']
else:
    app.config['MFA_REQUIRED_FOR_ROLE'] = []
app.config['MFA_ROLES'] = daconfig['two factor authentication'].get('allowed for', ['admin', 'developer'])
if not (app.config['MFA_ALLOW_SMS'] or app.config['MFA_ALLOW_APP']):
    app.config['USE_MFA'] = False
app.config['API_ROLES'] = daconfig.get('api privileges', ['admin', 'developer'])
app.config['WTF_CSRF_TIME_LIMIT'] = 604800
app.config['WTF_CSRF_SSL_STRICT'] = daconfig.get('require referer', (True if daconfig.get('cross site domains', None) is None else False))
app.config['USER_APP_NAME'] = app.config['APP_NAME']
app.config['USER_SEND_PASSWORD_CHANGED_EMAIL'] = False
app.config['USER_SEND_REGISTERED_EMAIL'] = True if daconfig.get('confirm registration', False) else False
app.config['USER_SEND_USERNAME_CHANGED_EMAIL'] = False
app.config['USER_ENABLE_RETYPE_PASSWORD'] = True if daconfig.get('retype password', True) else False
app.config['USER_ENABLE_REMEMBER_ME'] = False
app.config['USER_ENABLE_EMAIL'] = True
app.config['USER_ENABLE_USERNAME'] = False
app.config['USER_ENABLE_REGISTRATION'] = True
app.config['USER_ENABLE_CHANGE_USERNAME'] = False
app.config['USER_ENABLE_CONFIRM_EMAIL'] = True if daconfig.get('confirm registration', False) else False
app.config['USER_ENABLE_LOGIN_WITHOUT_CONFIRM_EMAIL'] = False if daconfig.get('confirm registration', False) else True
app.config['USER_AUTO_LOGIN_AFTER_REGISTER'] = False if daconfig.get('confirm registration', False) else True
app.config['USER_SHOW_USERNAME_EMAIL_DOES_NOT_EXIST'] = False if daconfig.get('confirm registration', False) else True
app.config['USER_AUTO_LOGIN_AFTER_RESET_PASSWORD'] = False
app.config['USER_AFTER_FORGOT_PASSWORD_ENDPOINT'] = 'user.login'
github jhpyle / docassemble / docassemble_webapp / docassemble / webapp / worker.py View on Github external
def make_png_for_pdf(doc, prefix, resolution, user_code, pdf_to_png, page=None):
    sys.stderr.write("make_png_for_pdf started in worker for size " + prefix + "\n")
    if not hasattr(worker_controller, 'loaded'):
        initialize_db()
    url_root = daconfig.get('url root', 'http://localhost') + daconfig.get('root', '/')
    url = url_root + 'interview'
    with worker_controller.flaskapp.app_context():
        with worker_controller.flaskapp.test_request_context(base_url=url_root, path=url):
            worker_controller.functions.reset_local_variables()
            worker_controller.functions.set_uid(user_code)
            worker_controller.ocr.make_png_for_pdf(doc, prefix, resolution, pdf_to_png, page=page)
            return