Add awareness for Email.dynamic_to flag in config UI

i.e. show help text and do not allow edit, when relevant
This commit is contained in:
Lance Edgar 2018-04-01 17:14:00 -07:00
parent eb45b9f8d9
commit 8c211df633

View file

@ -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))