Add 'To' field to email profile settings grid.

This commit is contained in:
Lance Edgar 2015-12-05 14:39:19 -06:00
parent 47603ad070
commit 57dd81d409

View file

@ -61,16 +61,21 @@ class ProfilesView(MasterView):
return data return data
def normalize(self, email): def normalize(self, email):
def get_recips(type_):
recips = email.get_recips(type_)
if recips:
return ', '.join(recips)
return { return {
'key': email.key, 'key': email.key,
'fallback_key': email.fallback_key,
'description': email.__doc__, 'description': email.__doc__,
'prefix': email.get_prefix(), 'prefix': email.get_prefix(),
'subject': email.get_subject(), 'subject': email.get_subject(),
'sender': email.get_sender(), 'sender': email.get_sender(),
'replyto': email.get_replyto(), 'replyto': email.get_replyto(),
'to': email.get_recips('to'), 'to': get_recips('to'),
'cc': email.get_recips('cc'), 'cc': get_recips('cc'),
'bcc': email.get_recips('bcc'), 'bcc': get_recips('bcc'),
} }
def configure_grid(self, g): def configure_grid(self, g):
@ -78,11 +83,13 @@ class ProfilesView(MasterView):
GridColumn('key'), GridColumn('key'),
GridColumn('prefix'), GridColumn('prefix'),
GridColumn('subject'), GridColumn('subject'),
GridColumn('to'),
] ]
g.sorters['key'] = g.make_sorter('key', foldcase=True) g.sorters['key'] = g.make_sorter('key', foldcase=True)
g.sorters['prefix'] = g.make_sorter('prefix', foldcase=True) g.sorters['prefix'] = g.make_sorter('prefix', foldcase=True)
g.sorters['subject'] = g.make_sorter('subject', foldcase=True) g.sorters['subject'] = g.make_sorter('subject', foldcase=True)
g.sorters['to'] = g.make_sorter('to', foldcase=True)
g.default_sortkey = 'key' g.default_sortkey = 'key'
# g.main_actions = [] # g.main_actions = []
@ -116,14 +123,15 @@ class ProfilesView(MasterView):
form.fieldset = forms.FieldSet() form.fieldset = forms.FieldSet()
form.fieldset.fields['key'] = forms.Field('key', value=email['key']) form.fieldset.fields['key'] = forms.Field('key', value=email['key'])
form.fieldset.fields['fallback_key'] = forms.Field('fallback_key', value=email['fallback_key'])
form.fieldset.fields['prefix'] = forms.Field('prefix', value=email['prefix'], label="Subject Prefix") form.fieldset.fields['prefix'] = forms.Field('prefix', value=email['prefix'], label="Subject Prefix")
form.fieldset.fields['subject'] = forms.Field('subject', value=email['subject'], label="Subject Text") form.fieldset.fields['subject'] = forms.Field('subject', value=email['subject'], label="Subject Text")
form.fieldset.fields['description'] = forms.Field('description', value=email['description']) form.fieldset.fields['description'] = forms.Field('description', value=email['description'])
form.fieldset.fields['sender'] = forms.Field('sender', value=email['sender'], label="From") form.fieldset.fields['sender'] = forms.Field('sender', value=email['sender'], label="From")
form.fieldset.fields['replyto'] = forms.Field('replyto', value=email['replyto'], label="Reply-To") form.fieldset.fields['replyto'] = forms.Field('replyto', value=email['replyto'], label="Reply-To")
form.fieldset.fields['to'] = forms.Field('to', value=', '.join(email['to']) if email['to'] else None) form.fieldset.fields['to'] = forms.Field('to', value=email['to'])
form.fieldset.fields['cc'] = forms.Field('cc', value=', '.join(email['cc']) if email['cc'] else None) form.fieldset.fields['cc'] = forms.Field('cc', value=email['cc'])
form.fieldset.fields['bcc'] = forms.Field('bcc', value=', '.join(email['bcc']) if email['bcc'] else None) form.fieldset.fields['bcc'] = forms.Field('bcc', value=email['bcc'])
return form return form