Skip to content

Commit

Permalink
Issue #432 - Derive bug title summary from selected radio choice
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Taylor committed Mar 5, 2015
1 parent e6de093 commit af9f3c3
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions webcompat/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
problem_choices = [
(u'detection_bug', u'Desktop site instead of mobile site'),
(u'mobile_site_bug', u'Mobile site is not usable'),
(u'video_bug', u'Video does\'nt play'),
(u'video_bug', u'Video doesn\'t play'),
(u'layout_bug', u'Layout is messed up'),
(u'text_bug', u'Text is not visible'),
(u'unknown_bug', u'Somethign else - I\'ll add details below')
Expand Down Expand Up @@ -64,6 +64,14 @@ def get_problem(category):
return u'Unknown'


def get_problem_summary(category):
'''Allows us to special case the "Other" radio choice summary.'''
if category == 'unknown_bug':
return u'see bug description'
else:
return get_problem(category).lower()

This comment has been minimized.

Copy link
@karlcow

karlcow Jun 22, 2017

Member

@miketaylr Working on #1587 I have a question about this one.
.lower() is used here. get_problem() doesn't make the string lowercase, but get_problem_summary() does. Any reasons?

This comment has been minimized.

Copy link
@karlcow

karlcow Jun 22, 2017

Member

ah understood. myself. OK. I will change a bit the description of the function in my commit. So it's more explicit.



def wrap_label(label):
'''Helper method to wrap a label and its type in an HTML comment.
Expand Down Expand Up @@ -138,10 +146,11 @@ def build_formdata(form_object):
normalized_url = normalize_url(url)
# Domain extraction
domain = domain_name(normalized_url)
problem_summary = get_problem_summary(form_object.get('problem_category'))
if domain:
summary = '{0} - {1}'.format(domain, form_object.get('summary'))
summary = '{0} - {1}'.format(domain, problem_summary)
else:
summary = '{0}'.format(form_object.get('summary'))
summary = '{0} - {1}'.format(normalized_url, problem_summary)
# Preparing the body
body = u'''{browser_label}{ua_label}
**URL**: {url}
Expand All @@ -160,6 +169,6 @@ def build_formdata(form_object):
description=form_object.get('description')
)
result = {}
result['title'] = 'TODO: Get the title from the selected choice'
result['title'] = summary
result['body'] = body
return result

0 comments on commit af9f3c3

Please sign in to comment.