Fix text area behavior for email recipient fields

This commit is contained in:
Lance Edgar 2018-03-12 18:27:50 -05:00
parent 85f108d10e
commit 69f04beb6d

View file

@ -205,6 +205,28 @@ class ProfilesView(MasterView):
return kwargs
class RecipientsType(colander.String):
"""
Custom schema type for email recipients. This is used to present the
recipients as a "list" within the text area, i.e. one recipient per line.
Then the list is collapsed to a comma-delimited string for storage.
"""
def serialize(self, node, appstruct):
if appstruct is colander.null:
return colander.null
recips = parse_list(appstruct)
return '\n'.join(recips)
def deserialize(self, node, cstruct):
if cstruct == '' and self.allow_empty:
return ''
if not cstruct:
return colander.null
recips = parse_list(cstruct)
return ', '.join(recips)
class EmailProfileSchema(colander.MappingSchema):
prefix = colander.SchemaNode(colander.String())
@ -215,11 +237,11 @@ class EmailProfileSchema(colander.MappingSchema):
replyto = colander.SchemaNode(colander.String(), missing='')
to = colander.SchemaNode(colander.String())
to = colander.SchemaNode(RecipientsType())
cc = colander.SchemaNode(colander.String(), missing='')
cc = colander.SchemaNode(RecipientsType(), missing='')
bcc = colander.SchemaNode(colander.String(), missing='')
bcc = colander.SchemaNode(RecipientsType(), missing='')
enabled = colander.SchemaNode(colander.Boolean())