0001-misc-replace-get_logger-.error-with-newer-record_err.patch
tests/form_pages/test_formdata.py | ||
---|---|---|
761 | 761 |
http_post_request.return_value = None, 400, 'null', None # fail |
762 | 762 |
resp = resp.form.submit('button_export_to') |
763 | 763 |
assert http_post_request.call_count == 1 |
764 |
assert caplog.records[-1].message.startswith( |
|
765 |
"file 'template.pdf' failed to be pushed to portfolio of 'Foo" |
|
766 |
) |
|
764 |
if pub.is_using_postgresql(): |
|
765 |
assert pub.loggederror_class.select()[0].summary.startswith( |
|
766 |
"file 'template.pdf' failed to be pushed to portfolio of 'Foo" |
|
767 |
) |
|
767 | 768 | |
768 | 769 |
# failed to push to portfolio, but document is here |
769 | 770 |
resp = resp.follow() # $form/$id/create_doc |
tests/test_fc_auth.py | ||
---|---|---|
194 | 194 |
} |
195 | 195 |
) |
196 | 196 |
) |
197 |
assert 'user did not authorize login' in caplog.records[-1].message |
|
197 |
if pub.is_using_postgresql(): |
|
198 |
assert 'user did not authorize login' in pub.loggederror_class.select()[-1].summary |
|
198 | 199 |
resp = app.get( |
199 | 200 |
'/ident/fc/callback?%s' |
200 | 201 |
% urllib.parse.urlencode( |
... | ... | |
204 | 205 |
} |
205 | 206 |
) |
206 | 207 |
) |
207 |
assert 'whatever' in caplog.records[-1].message |
|
208 |
if pub.is_using_postgresql(): |
|
209 |
assert 'whatever' in pub.loggederror_class.select()[-1].summary |
|
208 | 210 | |
209 | 211 |
# Login existing user |
210 | 212 |
def logme(login_url): |
wcs/backoffice/management.py | ||
---|---|---|
205 | 205 |
try: |
206 | 206 |
sms_class.send(sender, [form.get_widget('sms').parse()], message) |
207 | 207 |
except errors.SMSError as e: |
208 |
get_logger().error(e)
|
|
208 |
get_publisher().record_error(_('Could not send SMS'), formdata=formdata, exception=e)
|
|
209 | 209 |
get_session().message = ('info', _('SMS with tracking code sent to the user')) |
210 | 210 |
else: |
211 | 211 |
# send mail |
wcs/portfolio.py | ||
---|---|---|
62 | 62 |
def push_document(user, filename, stream): |
63 | 63 |
if not user: |
64 | 64 |
return |
65 |
charset = get_publisher().site_charset |
|
65 |
publisher = get_publisher() |
|
66 |
charset = publisher.site_charset |
|
66 | 67 |
payload = {} |
67 | 68 |
if user.name_identifiers: |
68 | 69 |
payload['user_nameid'] = force_text(user.name_identifiers[0], 'ascii') |
69 | 70 |
elif user.email: |
70 | 71 |
payload['user_email'] = force_text(user.email, 'ascii') |
71 |
payload['origin'] = urllib.parse.urlparse(get_publisher().get_frontoffice_url()).netloc
|
|
72 |
payload['origin'] = urllib.parse.urlparse(publisher.get_frontoffice_url()).netloc
|
|
72 | 73 |
payload['file_name'] = force_text(filename, charset) |
73 | 74 |
stream.seek(0) |
74 | 75 |
payload['file_b64_content'] = force_text(base64.b64encode(stream.read())) |
... | ... | |
80 | 81 |
if status == 200: |
81 | 82 |
get_logger().info('file %r pushed to portfolio of %r', filename, user.display_name) |
82 | 83 |
else: |
83 |
get_logger().error('file %r failed to be pushed to portfolio of %r', filename, user.display_name) |
|
84 |
publisher.record_error( |
|
85 |
_('file %(filename)r failed to be pushed to portfolio of %(display_name)r') |
|
86 |
% {'filename': filename, 'display_name': user.display_name} |
|
87 |
) |
|
84 | 88 | |
85 | 89 |
if get_response(): |
86 | 90 |
get_response().add_after_job( |
wcs/qommon/emails.py | ||
---|---|---|
43 | 43 |
from django.utils.safestring import mark_safe |
44 | 44 |
from quixote import get_publisher, get_request, get_response |
45 | 45 | |
46 |
from . import errors, force_str |
|
46 |
from . import _, errors, force_str
|
|
47 | 47 |
from .admin.emails import EmailsDirectory |
48 | 48 |
from .publisher import get_cfg, get_logger |
49 | 49 |
from .template import Template |
... | ... | |
350 | 350 | |
351 | 351 | |
352 | 352 |
def create_smtp_server(emails_cfg, smtp_timeout=None): |
353 |
publisher = get_publisher() |
|
353 | 354 |
try: |
354 | 355 |
s = smtplib.SMTP(emails_cfg.get('smtp_server', None) or 'localhost', timeout=smtp_timeout) |
355 |
except socket.timeout: |
|
356 |
get_logger().error('Failed to connect to SMTP server (timeout)')
|
|
356 |
except socket.timeout as e:
|
|
357 |
publisher.record_error(_('Failed to connect to SMTP server (timeout)'), exception=e)
|
|
357 | 358 |
raise errors.EmailError('Failed to connect to SMTP server (timeout)') |
358 | 359 |
except OSError: |
359 | 360 |
# XXX: write message in a queue somewhere? |
360 |
get_logger().error('Failed to connect to SMTP server')
|
|
361 |
publisher.record_error(_('Failed to connect to SMTP server'), exception=e)
|
|
361 | 362 |
raise errors.EmailError('Failed to connect to SMTP server') |
362 | 363 |
if not s.sock: |
363 |
get_logger().error('Failed to connect to SMTP server')
|
|
364 |
publisher.record_error(_('Failed to connect to SMTP server'))
|
|
364 | 365 |
raise errors.EmailError('Failed to connect to SMTP server') |
365 | 366 |
rc_code, ehlo_answer = s.ehlo() |
366 | 367 |
if rc_code != 250: |
367 |
get_logger().error('Failed to EHLO to SMTP server (%s)', rc_code)
|
|
368 |
publisher.record_error(_('Failed to EHLO to SMTP server (%s)') % rc_code)
|
|
368 | 369 |
raise errors.EmailError('Failed to EHLO to SMTP server (%s)' % rc_code) |
369 | 370 |
if b'STARTTLS' in ehlo_answer: |
370 | 371 |
rc_code = s.starttls()[0] |
371 | 372 |
if rc_code != 220: |
372 |
get_logger().error('Failed to STARTTLS to SMTP server (%s)', rc_code)
|
|
373 |
publisher.record_error(_('Failed to STARTTLS to SMTP server (%s)') % rc_code)
|
|
373 | 374 |
raise errors.EmailError('Failed to STARTTLS to SMTP server (%s)' % rc_code) |
374 | 375 |
if emails_cfg.get('smtp_login'): |
375 | 376 |
try: |
376 | 377 |
s.login(emails_cfg.get('smtp_login') or '', emails_cfg.get('smtp_password') or '') |
377 |
except smtplib.SMTPAuthenticationError: |
|
378 |
get_logger().error('Failed to authenticate to SMTP server')
|
|
378 |
except smtplib.SMTPAuthenticationError as e:
|
|
379 |
publisher.record_error(_('Failed to authenticate to SMTP server'), exception=e)
|
|
379 | 380 |
raise errors.EmailError('Failed to authenticate to SMTP server') |
380 |
except smtplib.SMTPException: |
|
381 |
get_logger().error('Failed to authenticate to SMTP server, unknown error.')
|
|
381 |
except smtplib.SMTPException as e:
|
|
382 |
publisher.record_error(_('Failed to authenticate to SMTP server, unknown error.'), exception=e)
|
|
382 | 383 |
raise errors.EmailError('Failed to authenticate to SMTP server, unknown error.') |
383 | 384 |
return s |
384 | 385 |
wcs/qommon/ident/franceconnect.py | ||
---|---|---|
28 | 28 |
from wcs.formdata import flatten_dict |
29 | 29 |
from wcs.workflows import WorkflowStatusItem |
30 | 30 | |
31 |
from .. import _, get_cfg, get_logger, template
|
|
31 |
from .. import _, get_cfg, template |
|
32 | 32 |
from ..backoffice.menu import html_top |
33 | 33 |
from ..form import ( |
34 | 34 |
CompositeWidget, |
... | ... | |
324 | 324 |
return False |
325 | 325 | |
326 | 326 |
def get_access_token(self, code): |
327 |
logger = get_logger()
|
|
327 |
publisher = get_publisher()
|
|
328 | 328 |
session = get_session() |
329 | 329 |
fc_cfg = get_cfg('fc', {}) |
330 | 330 |
client_id = fc_cfg.get('client_id') |
... | ... | |
345 | 345 |
}, |
346 | 346 |
) |
347 | 347 |
if status != 200: |
348 |
logger.error('status from FranceConnect token_url is not 200')
|
|
348 |
publisher.record_error(_('Status from FranceConnect token_url is not 200'))
|
|
349 | 349 |
return None |
350 | 350 |
result = json_loads(data) |
351 | 351 |
if 'error' in result: |
352 |
logger.error('FranceConnect code resolution failed: %s', result['error'])
|
|
352 |
publisher.record_error(_('FranceConnect code resolution failed: %s') % result['error'])
|
|
353 | 353 |
return None |
354 | 354 |
# check id_token nonce |
355 | 355 |
id_token = result['id_token'] |
... | ... | |
358 | 358 |
payload = json_loads(base64url_decode(force_bytes(payload))) |
359 | 359 |
nonce = hashlib.sha256(force_bytes(session.id)).hexdigest() |
360 | 360 |
if payload['nonce'] != nonce: |
361 |
logger.error('FranceConnect returned nonce did not match')
|
|
361 |
publisher.record_error(_('FranceConnect returned nonce did not match'))
|
|
362 | 362 |
return None |
363 | 363 |
return access_token, id_token |
364 | 364 | |
365 | 365 |
def get_user_info(self, access_token): |
366 |
logger = get_logger()
|
|
366 |
publisher = get_publisher()
|
|
367 | 367 |
dummy, status, data, dummy = http_get_page( |
368 | 368 |
self.get_user_info_url(), |
369 | 369 |
headers={ |
... | ... | |
371 | 371 |
}, |
372 | 372 |
) |
373 | 373 |
if status != 200: |
374 |
logger.error(
|
|
375 |
'status from FranceConnect user_info_url is not 200 but %s and data is' ' %s',
|
|
376 |
status.data[:100],
|
|
374 |
publisher.record_error(
|
|
375 |
_('Status from FranceConnect user_info_url is not 200 but %(status)s and data is %(data)s')
|
|
376 |
% {'status': status, 'data': data[:100]}
|
|
377 | 377 |
) |
378 | 378 |
return None |
379 | 379 |
return json_loads(data) |
... | ... | |
452 | 452 |
pub = get_publisher() |
453 | 453 |
request = get_request() |
454 | 454 |
session = get_session() |
455 |
logger = get_logger() |
|
456 | 455 |
state = request.form.get('state', '') |
457 | 456 |
next_url = (session.extra_user_variables or {}).pop( |
458 | 457 |
'fc_next_url_' + state, '' |
... | ... | |
464 | 463 |
if error: |
465 | 464 |
# we log only errors whose user is not responsible |
466 | 465 |
msg = self.AUTHORIZATION_REQUEST_ERRORS.get(error) |
467 |
logger.error(_('FranceConnect authentication failed: %s'), msg if msg else error)
|
|
466 |
pub.record_error(_('FranceConnect authentication failed: %s') % msg if msg else error)
|
|
468 | 467 |
return redirect(next_url) |
469 | 468 |
access_token, id_token = self.get_access_token(request.form['code']) |
470 | 469 |
if not access_token: |
... | ... | |
493 | 492 | |
494 | 493 |
if not (user.name and user.email): |
495 | 494 |
# we didn't get useful attributes, forget it. |
496 |
logger.error('failed to get name and/or email attribute from FranceConnect')
|
|
495 |
pub.record_error(_('Failed to get name and/or email attribute from FranceConnect'))
|
|
497 | 496 |
return redirect(next_url) |
498 | 497 | |
499 | 498 |
user.store() |
wcs/qommon/ident/idp.py | ||
---|---|---|
29 | 29 |
from quixote.directory import Directory |
30 | 30 |
from quixote.html import TemplateIO, htmltext |
31 | 31 | |
32 |
from .. import _, errors, get_cfg, get_logger, misc, saml2utils, template, x509utils
|
|
32 |
from .. import _, errors, get_cfg, misc, saml2utils, template, x509utils |
|
33 | 33 |
from ..admin.menu import command_icon |
34 | 34 |
from ..backoffice.menu import html_top |
35 | 35 |
from ..form import ( |
... | ... | |
84 | 84 |
idps = get_cfg('idp', {}) |
85 | 85 | |
86 | 86 |
if not lasso: |
87 |
get_logger().error('/login unavailable - lasso is not installed') |
|
88 | 87 |
raise Exception("lasso is missing, idp method cannot be used") |
89 | 88 | |
90 | 89 |
if len(idps) == 0: |
wcs/qommon/ident/password.py | ||
---|---|---|
23 | 23 | |
24 | 24 |
from wcs.qommon.admin.texts import TextsDirectory |
25 | 25 | |
26 |
from .. import _, emails, errors, get_cfg, get_logger, misc, ngettext
|
|
26 |
from .. import _, emails, errors, get_cfg, misc, ngettext |
|
27 | 27 |
from .. import storage as st |
28 | 28 |
from .. import template, tokens |
29 | 29 |
from ..admin.emails import EmailsDirectory |
... | ... | |
606 | 606 | |
607 | 607 |
if identities_cfg.get('email-confirmation', False): |
608 | 608 |
if not user.email: |
609 |
get_logger().error(
|
|
609 |
get_publisher().record_error(
|
|
610 | 610 |
_( |
611 | 611 |
'Accounts are configured to require confirmation but accounts can be created without emails' |
612 | 612 |
) |
... | ... | |
624 | 624 | |
625 | 625 |
if passwords_cfg.get('generate', True): |
626 | 626 |
if not user.email: |
627 |
get_logger().error(
|
|
627 |
get_publisher().record_error(
|
|
628 | 628 |
_( |
629 | 629 |
'Accounts are configured to have a generated password ' |
630 | 630 |
'but accounts can be created without emails' |
wcs/qommon/saml2.py | ||
---|---|---|
79 | 79 |
try: |
80 | 80 |
return method(*args, **kwargs) |
81 | 81 |
except Exception as e: |
82 |
get_logger().error('Exception in method %r: %s; returning a SOAP error' % (method, e)) |
|
82 |
get_publisher().record_error( |
|
83 |
_('Exception in method %r: returning a SOAP error') % method, exception=e |
|
84 |
) |
|
83 | 85 |
fault = lasso.SoapFault.newFull('Internal Server Error', str(e)) |
84 | 86 |
body = lasso.SoapBody() |
85 | 87 |
body.any = [fault] |
... | ... | |
125 | 127 |
def _q_traverse(self, path): |
126 | 128 |
# if lasso is not installed, hide the saml endpoints |
127 | 129 |
if lasso is None: |
128 |
if does_idp_authentication(): |
|
129 |
rel_path = os.path.join('/saml', *path) |
|
130 |
get_logger().error('%s unavailable - lasso is not installed' % rel_path) |
|
131 | 130 |
raise errors.TraversalError() |
132 | 131 |
return Directory._q_traverse(self, path) |
133 | 132 |
wcs/root.py | ||
---|---|---|
82 | 82 |
method = ident_methods[0] |
83 | 83 |
try: |
84 | 84 |
return ident.login(method) |
85 |
except KeyError: |
|
86 |
msg = 'failed to login with method %s' % method
|
|
87 |
get_logger().error(msg)
|
|
85 |
except KeyError as e:
|
|
86 |
msg = _('Failed to login with method %s') % method
|
|
87 |
get_publisher().record_error(msg, exception=e)
|
|
88 | 88 |
return errors.TraversalError(msg) |
89 | 89 |
else: |
90 | 90 |
form = Form(enctype='multipart/form-data') |
... | ... | |
108 | 108 |
else: |
109 | 109 |
try: |
110 | 110 |
return ident.login(method) |
111 |
except KeyError: |
|
112 |
msg = 'failed to login with method %s' % method |
|
113 |
get_logger().error(msg) |
|
111 |
except KeyError as e: |
|
112 |
get_publisher().record_error( |
|
113 |
_('Failed to login with method %s') % method, exception=e |
|
114 |
) |
|
114 | 115 |
return errors.TraversalError() |
115 | 116 |
else: |
116 | 117 |
template.html_top(_('Login')) |
... | ... | |
148 | 149 |
method = ident_methods[0] |
149 | 150 |
try: |
150 | 151 |
return ident.register(method) |
151 |
except KeyError: |
|
152 |
get_logger().error('failed to register with method %s' % method)
|
|
152 |
except KeyError as e:
|
|
153 |
get_publisher().record_error(_('Failed to register with method %s') % method, exception=e)
|
|
153 | 154 |
return errors.TraversalError() |
154 | 155 |
else: |
155 | 156 |
form = Form(enctype='multipart/form-data') |
... | ... | |
332 | 333 |
} |
333 | 334 |
) |
334 | 335 |
except UploadStorageError as e: |
335 |
get_logger().error('upload storage error: %s' % e)
|
|
336 |
get_publisher().record_error(_('Upload storage error'), exception=e)
|
|
336 | 337 |
results.append({'error': _('failed to store file (system error)')}) |
337 | 338 | |
338 | 339 |
get_response().set_content_type('application/json') |
wcs/wf/export_to_model.py | ||
---|---|---|
45 | 45 |
template_on_formdata, |
46 | 46 |
) |
47 | 47 | |
48 |
from ..qommon import _, ezt, force_str, get_logger, misc
|
|
48 |
from ..qommon import _, ezt, force_str, misc |
|
49 | 49 |
from ..qommon.form import ( |
50 | 50 |
CheckboxWidget, |
51 | 51 |
ComputedExpressionWidget, |
... | ... | |
509 | 509 |
) |
510 | 510 |
) |
511 | 511 |
except TemplateError as e: |
512 |
url = formdata.get_url() |
|
513 |
get_logger().error('error in template for export to model [%s]: %s' % (url, str(e))) |
|
512 |
get_publisher().record_error( |
|
513 |
_('Error in template for export to model'), formdata=formdata, exception=e |
|
514 |
) |
|
514 | 515 |
raise TemplatingError(_('Error in template: %s') % str(e)) |
515 | 516 | |
516 | 517 |
def apply_od_template_to_formdata(self, formdata): |
wcs/wf/notification.py | ||
---|---|---|
20 | 20 | |
21 | 21 |
from wcs.workflows import WorkflowStatusItem, register_item_class, template_on_formdata |
22 | 22 | |
23 |
from ..qommon import _, get_logger
|
|
23 |
from ..qommon import _ |
|
24 | 24 |
from ..qommon.form import ComputedExpressionWidget, SingleSelectWidget, StringWidget, TextWidget, WidgetList |
25 | 25 |
from ..qommon.template import TemplateError |
26 | 26 |
from .wscall import WebserviceCallStatusItem |
... | ... | |
124 | 124 |
try: |
125 | 125 |
title = template_on_formdata(formdata, self.compute(self.title, render=False), autoescape=False) |
126 | 126 |
except TemplateError as e: |
127 |
get_logger().error(
|
|
128 |
'error in template for notification title, ' 'mail could not be generated: %s' % str(e)
|
|
127 |
get_publisher().record_error(
|
|
128 |
_('error in template for notification title, mail could not be generated'), exception=e
|
|
129 | 129 |
) |
130 | 130 |
return |
131 | 131 | |
132 | 132 |
try: |
133 | 133 |
body = template_on_formdata(formdata, self.compute(self.body, render=False), autoescape=False) |
134 | 134 |
except TemplateError as e: |
135 |
get_logger().error(
|
|
136 |
'error in template for notification body, ' 'mail could not be generated: %s' % str(e)
|
|
135 |
get_publisher().record_error(
|
|
136 |
_('error in template for notification body, mail could not be generated'), exception=e
|
|
137 | 137 |
) |
138 | 138 |
return |
139 | 139 |
wcs/wf/profile.py | ||
---|---|---|
29 | 29 |
from ..qommon.form import CompositeWidget, ComputedExpressionWidget, SingleSelectWidget, WidgetListAsTable |
30 | 30 |
from ..qommon.ident.idp import is_idp_managing_user_attributes |
31 | 31 |
from ..qommon.misc import JSONEncoder, http_patch_request |
32 |
from ..qommon.publisher import get_cfg, get_logger
|
|
32 |
from ..qommon.publisher import get_cfg |
|
33 | 33 | |
34 | 34 | |
35 | 35 |
def user_ws_url(user_uuid): |
... | ... | |
207 | 207 |
url, payload, headers={'Content-type': 'application/json'} |
208 | 208 |
) |
209 | 209 |
if status != 200: |
210 |
get_logger().error('failed to update profile for user %r', user)
|
|
210 |
get_publisher().record_error(_('Failed to update profile for user %r') % user)
|
|
211 | 211 | |
212 | 212 |
if get_request(): |
213 | 213 |
get_response().add_after_job(_('Updating user profile'), after_job) |
wcs/wf/register_comment.py | ||
---|---|---|
25 | 25 |
template_on_formdata, |
26 | 26 |
) |
27 | 27 | |
28 |
from ..qommon import _, ezt, get_logger
|
|
28 |
from ..qommon import _, ezt |
|
29 | 29 |
from ..qommon.form import SingleSelectWidget, TextWidget, WidgetList |
30 | 30 |
from ..qommon.template import TemplateError |
31 | 31 | |
... | ... | |
139 | 139 |
formdata.evolution[-1].add_part(JournalEvolutionPart(formdata, self.comment, self.to)) |
140 | 140 |
formdata.store() |
141 | 141 |
except TemplateError as e: |
142 |
url = formdata.get_url() |
|
143 |
get_logger().error( |
|
144 |
'error in template for comment [%s], ' 'comment could not be generated: %s' % (url, str(e)) |
|
142 |
get_publisher().record_error( |
|
143 |
_('Error in template, comment could not be generated'), formdata=formdata, exception=e |
|
145 | 144 |
) |
146 | 145 | |
147 | 146 |
wcs/wf/roles.py | ||
---|---|---|
26 | 26 |
from ..qommon.form import SingleSelectWidgetWithOther |
27 | 27 |
from ..qommon.ident.idp import is_idp_managing_user_attributes |
28 | 28 |
from ..qommon.misc import http_delete_request, http_post_request |
29 |
from ..qommon.publisher import get_cfg, get_logger
|
|
29 |
from ..qommon.publisher import get_cfg |
|
30 | 30 | |
31 | 31 | |
32 | 32 |
def roles_ws_url(role_uuid, user_uuid): |
... | ... | |
112 | 112 |
signed_url = sign_ws_url(url) |
113 | 113 |
dummy, status, dummy, dummy = http_post_request(signed_url) |
114 | 114 |
if status != 201: |
115 |
get_logger().error('failed to add role %r to user %r', role, user) |
|
115 |
get_publisher().record_error( |
|
116 |
_('Failed to add role %(role)r to user %(user)r') % {'role': role, 'user': user}, |
|
117 |
formdata=formdata, |
|
118 |
) |
|
116 | 119 | |
117 | 120 |
if get_request(): |
118 | 121 |
get_response().add_after_job(_('Adding role'), after_job) |
... | ... | |
183 | 186 |
# pylint: disable=unused-variable |
184 | 187 |
response, status, data, auth_header = http_delete_request(signed_url) |
185 | 188 |
if status != 200: |
186 |
get_logger().error('failed to remove role %r from user %r', role, user) |
|
189 |
get_publisher().record_error( |
|
190 |
_('Failed to remove role %(role)r from user %(user)r') % {'role': role, 'user': user}, |
|
191 |
formdata=formdata, |
|
192 |
) |
|
187 | 193 | |
188 | 194 |
if get_request(): |
189 | 195 |
get_response().add_after_job(_('Removing role'), after_job) |
wcs/workflows.py | ||
---|---|---|
35 | 35 |
from .formdata import Evolution |
36 | 36 |
from .formdef import FormDef, FormdefImportError |
37 | 37 |
from .mail_templates import MailTemplate |
38 |
from .qommon import _, emails, errors, ezt, force_str, get_cfg, get_logger, misc
|
|
38 |
from .qommon import _, emails, errors, ezt, force_str, get_cfg, misc |
|
39 | 39 |
from .qommon.form import ( |
40 | 40 |
CheckboxWidget, |
41 | 41 |
ComputedExpressionWidget, |
... | ... | |
3005 | 3005 |
if not (self.subject and self.body) and not self.mail_template: |
3006 | 3006 |
return |
3007 | 3007 | |
3008 |
url = formdata.get_url() |
|
3009 | 3008 |
body = self.body |
3010 | 3009 |
subject = self.subject |
3011 | 3010 |
extra_attachments = None |
... | ... | |
3028 | 3027 |
formdata, self.compute(body, render=False), autoescape=body.startswith('<') |
3029 | 3028 |
) |
3030 | 3029 |
except TemplateError as e: |
3031 |
get_logger().error(
|
|
3032 |
'error in template for email body [%s], ' 'mail could not be generated: %s' % (url, str(e))
|
|
3030 |
get_publisher().record_error(
|
|
3031 |
_('Error in body template, mail could not be generated'), formdata=formdata, exception=e
|
|
3033 | 3032 |
) |
3034 | 3033 |
return |
3035 | 3034 | |
... | ... | |
3038 | 3037 |
formdata, self.compute(subject, render=False), autoescape=False |
3039 | 3038 |
) |
3040 | 3039 |
except TemplateError as e: |
3041 |
get_logger().error(
|
|
3042 |
'error in template for email subject [%s], ' 'mail could not be generated: %s' % (url, str(e))
|
|
3040 |
get_publisher().record_error(
|
|
3041 |
_('Error in subject template, mail could not be generated'), formdata=formdata, exception=e
|
|
3043 | 3042 |
) |
3044 | 3043 |
return |
3045 | 3044 | |
... | ... | |
3212 | 3211 |
try: |
3213 | 3212 |
sms_body = template_on_formdata(formdata, self.compute(self.body, render=False)) |
3214 | 3213 |
except TemplateError as e: |
3215 |
get_logger().error('error in template for sms [%s], sms could not be generated' % str(e)) |
|
3214 |
get_publisher().record_error( |
|
3215 |
_('Error in template, sms could not be generated'), formdata=formdata, exception=e |
|
3216 |
) |
|
3216 | 3217 |
return |
3217 | 3218 | |
3218 | 3219 |
from .qommon import sms |
... | ... | |
3222 | 3223 |
try: |
3223 | 3224 |
sms.SMS.get_sms_class().send(sender, destinations, sms_body) |
3224 | 3225 |
except errors.SMSError as e: |
3225 |
get_logger().error(e)
|
|
3226 |
get_publisher().record_error(_('Could not send SMS'), formdata=formdata, exception=e)
|
|
3226 | 3227 | |
3227 | 3228 | |
3228 | 3229 |
register_item_class(SendSMSWorkflowStatusItem) |
3229 |
- |