From 9d3a8e1f472a3aeb0a136d2cda41d165c1ac413f Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Tue, 11 Aug 2015 17:23:47 -0500 Subject: [PATCH] Issue #24. Only try to add an image to the issue... if there's an image. --- webcompat/form.py | 12 +++++++----- webcompat/views.py | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/webcompat/form.py b/webcompat/form.py index a939a35db..f5535b9ba 100644 --- a/webcompat/form.py +++ b/webcompat/form.py @@ -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 @@ -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 diff --git a/webcompat/views.py b/webcompat/views.py index 46fa032a2..201bcc1a9 100644 --- a/webcompat/views.py +++ b/webcompat/views.py @@ -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.