Fix text area behavior for email recipient fields
This commit is contained in:
parent
85f108d10e
commit
69f04beb6d
|
@ -205,6 +205,28 @@ class ProfilesView(MasterView):
|
||||||
return kwargs
|
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):
|
class EmailProfileSchema(colander.MappingSchema):
|
||||||
|
|
||||||
prefix = colander.SchemaNode(colander.String())
|
prefix = colander.SchemaNode(colander.String())
|
||||||
|
@ -215,11 +237,11 @@ class EmailProfileSchema(colander.MappingSchema):
|
||||||
|
|
||||||
replyto = colander.SchemaNode(colander.String(), missing='')
|
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())
|
enabled = colander.SchemaNode(colander.Boolean())
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue