wcs: add support for mail templates (#51573)

This commit is contained in:
Frédéric Péters 2021-03-05 08:56:00 +01:00
parent e31161283d
commit 61e3bb9c52
1 changed files with 17 additions and 0 deletions

View File

@ -7,6 +7,7 @@ from wcs.carddef import CardDef
from wcs.categories import Category
from wcs.data_sources import NamedDataSource
from wcs.formdef import FormDef
from wcs.mail_templates import MailTemplate
from wcs.workflows import Workflow
from wcs.wscalls import NamedWsCall
@ -32,6 +33,7 @@ class Cmd(Command):
self.import_categories()
self.import_datasources()
self.import_wscalls()
self.import_mail_templates()
self.import_workflows()
self.import_blocks()
self.import_carddefs()
@ -67,6 +69,21 @@ class Cmd(Command):
datasource.id = existing_datasource.id
datasource.store(comment='Indus Update')
def import_mail_templates(self):
if not os.path.exists(os.path.join(self.directory, 'mail-templates')):
return
for filename in os.listdir(os.path.join(self.directory, 'mail-templates')):
mail_template = MailTemplate.import_from_xml(
open(os.path.join(self.directory, 'mail-templates', filename))
)
existing_mail_template = MailTemplate.get_by_slug(mail_template.slug)
if existing_mail_template is None:
mail_template.store()
else:
# replace
mail_template.id = existing_mail_template.id
mail_template.store()
def import_workflows(self):
if not os.path.exists(os.path.join(self.directory, 'workflows')):
return