Add convenience functions for sanitizing downloaded rattail DB

for sake of dev and testing
This commit is contained in:
Lance Edgar 2018-11-21 23:49:02 -06:00
parent 36493885e7
commit 17aa1365aa

View file

@ -28,7 +28,7 @@ from __future__ import unicode_literals, absolute_import
from fabric.api import sudo, env, cd from fabric.api import sudo, env, cd
from rattail_fabric import make_deploy, make_system_user, mkdir from rattail_fabric import make_deploy, make_system_user, mkdir, postgresql
deploy = make_deploy(__file__) deploy = make_deploy(__file__)
@ -78,3 +78,19 @@ def deploy_rattail_sudoers(remote_path='/etc/sudoers.d/rattail'):
Deploy the common sudoers file for rattail. Deploy the common sudoers file for rattail.
""" """
deploy.sudoers('sudoers', remote_path) deploy.sudoers('sudoers', remote_path)
def delete_email_recipients(dbname):
"""
Purge all email recipient settings for the given database.
"""
postgresql.sql("delete from setting where name like 'rattail.mail.%.to';", database=dbname)
postgresql.sql("delete from setting where name like 'rattail.mail.%.cc';", database=dbname)
postgresql.sql("delete from setting where name like 'rattail.mail.%.bcc';", database=dbname)
def disable_emails(dbname):
"""
Disable all emails for the given database.
"""
postgresql.sql("update setting set value = 'false' where name like 'rattail.mail.%.enabled';", database=dbname)