diff --git a/rattail_fabric/rattail.py b/rattail_fabric/rattail.py index 8f8b94f..a6ba9dc 100644 --- a/rattail_fabric/rattail.py +++ b/rattail_fabric/rattail.py @@ -28,7 +28,7 @@ from __future__ import unicode_literals, absolute_import 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__) @@ -78,3 +78,19 @@ def deploy_rattail_sudoers(remote_path='/etc/sudoers.d/rattail'): Deploy the common sudoers file for rattail. """ 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)