From 8c211df633c29725af56add42ddb91f7e0579677 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 1 Apr 2018 17:14:00 -0700 Subject: [PATCH] Add awareness for `Email.dynamic_to` flag in config UI i.e. show help text and do not allow edit, when relevant --- tailbone/views/email.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tailbone/views/email.py b/tailbone/views/email.py index 6e12e972..d95be94d 100644 --- a/tailbone/views/email.py +++ b/tailbone/views/email.py @@ -87,19 +87,23 @@ class ProfilesView(MasterView): g.sorters['key'] = g.make_simple_sorter('key', foldcase=True) g.sorters['prefix'] = g.make_simple_sorter('prefix', foldcase=True) g.sorters['subject'] = g.make_simple_sorter('subject', foldcase=True) - g.sorters['to'] = g.make_simple_sorter('to', foldcase=True) g.sorters['enabled'] = g.make_simple_sorter('enabled') g.set_sort_defaults('key') g.set_type('enabled', 'boolean') - g.set_renderer('to', self.render_to) g.set_link('key') g.set_link('subject') - # Make edit link visible by default, no "More" actions. - if g.more_actions: - g.main_actions.append(g.more_actions.pop()) + # to + g.set_renderer('to', self.render_to_short) + g.sorters['to'] = g.make_simple_sorter('to', foldcase=True) + + def render_to_short(self, email, column): + profile = email['_email'] + if self.rattail_config.production(): + if profile.dynamic_to: + if profile.dynamic_to_help: + return profile.dynamic_to_help - def render_to(self, email, column): value = email['to'] if not value: return "" @@ -148,6 +152,7 @@ class ProfilesView(MasterView): def configure_form(self, f): super(ProfilesView, self).configure_form(f) + profile = f.model_instance['_email'] # key f.set_readonly('key') @@ -172,6 +177,11 @@ class ProfilesView(MasterView): # to f.set_widget('to', dfwidget.TextAreaWidget(cols=60, rows=6)) + if self.rattail_config.production(): + if profile.dynamic_to: + f.set_readonly('to') + if profile.dynamic_to_help: + f.model_instance['to'] = profile.dynamic_to_help # cc f.set_widget('cc', dfwidget.TextAreaWidget(cols=60, rows=2))