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:
parent
eb45b9f8d9
commit
8c211df633
|
@ -87,19 +87,23 @@ class ProfilesView(MasterView):
|
||||||
g.sorters['key'] = g.make_simple_sorter('key', foldcase=True)
|
g.sorters['key'] = g.make_simple_sorter('key', foldcase=True)
|
||||||
g.sorters['prefix'] = g.make_simple_sorter('prefix', foldcase=True)
|
g.sorters['prefix'] = g.make_simple_sorter('prefix', foldcase=True)
|
||||||
g.sorters['subject'] = g.make_simple_sorter('subject', 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.sorters['enabled'] = g.make_simple_sorter('enabled')
|
||||||
g.set_sort_defaults('key')
|
g.set_sort_defaults('key')
|
||||||
g.set_type('enabled', 'boolean')
|
g.set_type('enabled', 'boolean')
|
||||||
g.set_renderer('to', self.render_to)
|
|
||||||
g.set_link('key')
|
g.set_link('key')
|
||||||
g.set_link('subject')
|
g.set_link('subject')
|
||||||
|
|
||||||
# Make edit link visible by default, no "More" actions.
|
# to
|
||||||
if g.more_actions:
|
g.set_renderer('to', self.render_to_short)
|
||||||
g.main_actions.append(g.more_actions.pop())
|
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']
|
value = email['to']
|
||||||
if not value:
|
if not value:
|
||||||
return ""
|
return ""
|
||||||
|
@ -148,6 +152,7 @@ class ProfilesView(MasterView):
|
||||||
|
|
||||||
def configure_form(self, f):
|
def configure_form(self, f):
|
||||||
super(ProfilesView, self).configure_form(f)
|
super(ProfilesView, self).configure_form(f)
|
||||||
|
profile = f.model_instance['_email']
|
||||||
|
|
||||||
# key
|
# key
|
||||||
f.set_readonly('key')
|
f.set_readonly('key')
|
||||||
|
@ -172,6 +177,11 @@ class ProfilesView(MasterView):
|
||||||
|
|
||||||
# to
|
# to
|
||||||
f.set_widget('to', dfwidget.TextAreaWidget(cols=60, rows=6))
|
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
|
# cc
|
||||||
f.set_widget('cc', dfwidget.TextAreaWidget(cols=60, rows=2))
|
f.set_widget('cc', dfwidget.TextAreaWidget(cols=60, rows=2))
|
||||||
|
|
Loading…
Reference in a new issue