2049 |
2049 |
subject = None
|
2050 |
2050 |
body = None
|
2051 |
2051 |
custom_from = None
|
|
2052 |
attachments = None
|
2052 |
2053 |
|
2053 |
2054 |
comment = None
|
2054 |
2055 |
|
... | ... | |
2087 |
2088 |
return _('Send mail (not completed)')
|
2088 |
2089 |
|
2089 |
2090 |
def get_parameters(self):
|
2090 |
|
return ('to', 'subject', 'body', 'custom_from')
|
|
2091 |
return ('to', 'subject', 'body', 'attachments', 'custom_from')
|
2091 |
2092 |
|
2092 |
2093 |
def fill_admin_form(self, form):
|
2093 |
2094 |
self.add_parameters_widgets(form, self.get_parameters())
|
... | ... | |
2110 |
2111 |
value=self.body, cols=80, rows=10,
|
2111 |
2112 |
validation_function=ComputedExpressionWidget.validate_ezt,
|
2112 |
2113 |
hint=_('Available variables: url, url_status, details, name, number, comment, field_NAME'))
|
|
2114 |
|
|
2115 |
attachments_fields = [(None, '---', None)]
|
|
2116 |
attachments_bofields = []
|
|
2117 |
for field in self.parent.parent.get_backoffice_fields():
|
|
2118 |
if field.key != 'file':
|
|
2119 |
continue
|
|
2120 |
if field.varname:
|
|
2121 |
codename = 'form_var_%s' % field.varname
|
|
2122 |
else:
|
|
2123 |
codename = '__f%s' % field.id # __fbo<n>
|
|
2124 |
attachments_bofields.append(codename)
|
|
2125 |
attachments_fields.append((codename, field.label, codename))
|
|
2126 |
# don't show removed backoffice fields without varnames
|
|
2127 |
attachments = [attachment for attachment in self.attachments or []
|
|
2128 |
if ((not attachment.startswith('__f')) or (attachment in attachments_bofields))]
|
|
2129 |
if 'attachments' in parameters:
|
|
2130 |
if len(attachments_fields) > 1:
|
|
2131 |
form.add(WidgetList, '%sattachments' % prefix, title=_('Attachments'),
|
|
2132 |
element_type=SingleSelectWidgetWithOther,
|
|
2133 |
value=attachments,
|
|
2134 |
add_element_label=_('Add attachment'),
|
|
2135 |
element_kwargs={'render_br': False, 'options': attachments_fields,
|
|
2136 |
'other_label': _('Other (Python expression):')})
|
|
2137 |
else:
|
|
2138 |
form.add(WidgetList, '%sattachments' % prefix,
|
|
2139 |
title=_('Attachments (Python expressions)'),
|
|
2140 |
element_type=StringWidget,
|
|
2141 |
value=attachments,
|
|
2142 |
add_element_label=_('Add attachment'),
|
|
2143 |
element_kwargs={'render_br': False, 'size': 50},
|
|
2144 |
advanced=not(bool(self.attachments)))
|
|
2145 |
|
2113 |
2146 |
if 'custom_from' in parameters:
|
2114 |
2147 |
form.add(ComputedExpressionWidget, '%scustom_from' % prefix,
|
2115 |
2148 |
title=_('Custom From Address'), value=self.custom_from,
|
2116 |
|
-
|