Skip to content

Commit

Permalink
Issue #24. Only try to add an image to the issue... if there's an image.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Taylor committed Aug 11, 2015
1 parent f93464b commit 9d3a8e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 7 additions & 5 deletions webcompat/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,7 @@ def build_formdata(form_object):
'browser': form_object.get('browser'),
'os': form_object.get('os'),
'problem_type': get_problem(form_object.get('problem_category')),
'description': form_object.get('description'),
'image_name': form_object.get('image_upload')[0],
'image_url': form_object.get('image_upload')[1]
'description': form_object.get('description')
}

# Preparing the body
Expand All @@ -191,9 +189,13 @@ def build_formdata(form_object):
**Steps to Reproduce**
{description}
![{image_name}]({image_url})
'''.format(**formdata)
# Add the image, if there was one.
if form_object.get('image_upload') is not None:
body += '\n\n![{image_name}]({image_url})'.format(
image_name=form_object.get('image_upload')[0],
image_url=form_object.get('image_upload')[1])

result = {}
result['title'] = summary
result['body'] = body
Expand Down
3 changes: 2 additions & 1 deletion webcompat/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ def index():
form['ua_header'] = ua_header
# TODO: image upload spinner.
# Do we have an image ready to be uploaded?
if 'image' in request.files:
image = request.files['image']
if image:
form['image_upload'] = upload()
if form.get('submit-type') == AUTH_REPORT:
if g.user: # If you're already authed, submit the bug.
Expand Down

0 comments on commit 9d3a8e1

Please sign in to comment.