Skip to content

Commit

Permalink
Merge pull request #184 from ehenneken/feedback_logging
Browse files Browse the repository at this point in the history
log message for successful email
  • Loading branch information
ehenneken committed Dec 7, 2020
2 parents f0cdbba + 5a9634b commit 3094e3c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions adsws/feedback/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def send_feedback_email(name, sender, subject, data, attachments=None):
# Each entry is a tuple of file name and JSON data
msg.attach(attachment[0], "application/json", json.dumps(attachment[1]))
current_app.extensions['mail'].send(msg)
current_app.logger.info('Successfully sent email: data submitted by {0}, sent to {1} (form: {2})'.format(sender, email, subject))
return msg

def err(error_dictionary):
Expand Down
4 changes: 2 additions & 2 deletions adsws/feedback/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def post(self):
channel = post_data.get('channel', '#feedback')
username = post_data.get('username', 'TownCrier')
icon_emoji = current_app.config['FORM_SLACK_EMOJI']
text = 'Received data from feedback form "{0}" from {1} ({2})'.format(post_data.get('_subject'), post_data.get('name'), post_data.get('email'))
text = 'Received data from feedback form "{0}" from {1}'.format(post_data.get('_subject'), post_data.get('email'))
slack_data = {
'text': text,
'username': username,
Expand Down Expand Up @@ -180,7 +180,7 @@ def post(self):
email_sent = False
if not email_sent:
# If the email could not be sent, we can still log the data submitted
current_app.logger.error('Sending of email failed. Feedback data submitted by {0} ({1}): {2}'.format(post_data, name, post_data.get('email')))
current_app.logger.error('Sending of email failed. Feedback data submitted by {0}: {1}'.format(post_data.get('email'), post_data))
return err(ERROR_EMAIL_NOT_SENT)
# If we have Slack data, post the message to Slack
if slack_data:
Expand Down

0 comments on commit 3094e3c

Please sign in to comment.