handle if user doesn't provide name/email

also clean up usage of DESKPRO_PERSON_EMAIL and put it in the conf rather than env
This commit is contained in:
Leo Hemsted
2016-08-04 18:01:08 +01:00
parent ff46aaa6cc
commit d5238bce5b
8 changed files with 35 additions and 37 deletions

View File

@@ -8,18 +8,19 @@ from app.main.forms import Feedback
def feedback():
form = Feedback()
if form.validate_on_submit():
user_supplied_email = form.email_address.data != ''
feedback_msg = 'Environment: {}\n{}\n{}'.format(
url_for('main.index', _external=True),
'' if user_supplied_email else '{} (no email address supplied)'.format(form.name.data),
form.feedback.data
)
data = {
'person_email': form.email_address.data,
'person_name': form.name.data,
'person_email': form.email_address.data or current_app.config.get('DESKPRO_PERSON_EMAIL'),
'person_name': form.name.data or None,
'department_id': current_app.config.get('DESKPRO_DEPT_ID'),
'agent_team_id': current_app.config.get('DESKPRO_ASSIGNED_AGENT_TEAM_ID'),
'subject': 'Notify feedback',
'message': 'Environment: {}\n\n{}\n{}\n{}'.format(
url_for('main.index', _external=True),
form.name.data,
form.email_address.data,
form.feedback.data
)
'message': feedback_msg
}
headers = {
"X-DeskPRO-API-Key": current_app.config.get('DESKPRO_API_KEY'),

View File

@@ -108,9 +108,7 @@ def service_request_to_go_live(service_id):
'department_id': current_app.config.get('DESKPRO_DEPT_ID'),
'agent_team_id': current_app.config.get('DESKPRO_ASSIGNED_AGENT_TEAM_ID'),
'subject': 'Request to go live',
'message': "From {} <{}> on behalf of {} ({})\n\nUsage estimate\n---\n\n{}".format(
current_user.name,
current_user.email_address,
'message': "On behalf of {} ({})\n\nUsage estimate\n---\n\n{}".format(
current_service['name'],
url_for('main.service_dashboard', service_id=current_service['id'], _external=True),
form.usage.data