## -*- mode: conf; -*-

<%text>############################################################</%text>
#
# core config for Theo
#
<%text>############################################################</%text>


[theo]

## POS integration
% if env.theo_integrates_with == 'corepos':
integrate_corepos = true
% elif env.theo_integrates_with == 'catapult':
integrate_catapult = true
% elif env.theo_integrates_with == 'locsms':
integrate_locsms = true
% endif

## POS DB mirror
mirror_posdb = ${'true' if env.theo_mirror_posdb else 'false'}


## begin corepos
% if env.theo_integrates_with == 'corepos':

<%text>##############################</%text>
# CORE-POS
<%text>##############################</%text>

[corepos]
office.url = ${env.corepos_office_url}

[corepos.api]
url = ${env.corepos_api_url}

[corepos.db.office_op]
default.url = mysql+mysqlconnector://${env.corepos_db_username}:${env.corepos_db_password}@${env.corepos_db_host}/${env.corepos_db_name_office_op}
default.pool_recycle = 3600

## end corepos
% endif


## begin catapult
% if env.theo_integrates_with == 'catapult':

<%text>##############################</%text>
# Catapult
<%text>##############################</%text>

[catapult]
url = https://${env.catapult_host}/weboffice/

[catapult.db]
% if env.theo_mirror_posdb == 'mysql':
keys = default, mirror, production
default.url = mysql+mysqlconnector://rattail:${env.password_mysql_rattail}@localhost/${mirrordb}
mirror.url = mysql+mysqlconnector://rattail:${env.password_mysql_rattail}@localhost/${mirrordb}
production.url = catapult://${env.catapult_odbc_username}:${env.catapult_odbc_password}@catapult-production
% elif env.theo_mirror_posdb == 'postgresql':
keys = default, mirror, production
default.url = postgresql://rattail:${env.password_postgresql_rattail}@localhost/${mirrordb}
mirror.url = postgresql://rattail:${env.password_postgresql_rattail}@localhost/${mirrordb}
production.url = catapult://${env.catapult_odbc_username}:${env.catapult_odbc_password}@catapult-production
% else:
default.url = catapult://${env.catapult_odbc_username}:${env.catapult_odbc_password}@catapult-production
% endif

## end catapult
% endif


## begin locsms
% if env.theo_integrates_with == 'locsms':

<%text>##############################</%text>
# LOC SMS
<%text>##############################</%text>

[locsms.db]
default.url = mssql://${env.locsms_odbc_username}:${env.locsms_odbc_password}@locsms-default

## end locsms
% endif


<%text>##############################</%text>
# rattail
<%text>##############################</%text>

[rattail]
production = ${'true' if production else 'false'}
appdir = ${envroot}/app
datadir = ${envroot}/app/data
batch.files = ${envroot}/app/batch
workdir = ${envroot}/app/work
runas.default = theo

[rattail.config]
include = /etc/rattail/rattail.conf
usedb = true
preferdb = true

[rattail.db]
default.url = postgresql://rattail:${env.password_postgresql_rattail}@localhost/${dbname}
versioning.enabled = true

[rattail.mail]
send_emails = true
default.prefix = [Theo]

[rattail.upgrades]
command = sudo ${envroot}/app/upgrade-wrapper.sh --verbose
files = ${envroot}/app/data/upgrades


<%text>##############################</%text>
# alembic
<%text>##############################</%text>

[alembic]
script_location = rattail.db:alembic
% if env.theo_integrates_with == 'corepos':
version_locations = rattail_corepos.db:alembic/versions rattail.db:alembic/versions
% elif env.theo_integrates_with == 'catapult':
version_locations = rattail_onager.db:alembic/versions rattail.db:alembic/versions
% elif env.theo_integrates_with == 'locsms':
version_locations = rattail_luckysmores.db:alembic/versions rattail.db:alembic/versions
% else:
version_locations = rattail.db:alembic/versions
% endif


<%text>##############################</%text>
# logging
<%text>##############################</%text>

[handler_file]
args = ('${envroot}/app/log/rattail.log', 'a', 'utf_8')

[handler_email]
args = ('localhost', '${env.email_default_sender}', ${env.email_default_recipients}, "[Theo${'' if production else ' (stage)'}] Logging")