From 09853fb7abf48f77866840c70d4a3a928b53ae7c Mon Sep 17 00:00:00 2001 From: Karl Dubost Date: Tue, 14 Jul 2020 11:28:52 +0900 Subject: [PATCH] Issue #3380 - simplifies PrefixedRadioField This optimizes a bit the code to make it easier to read. It doesn't change the global logic --- webcompat/form.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/webcompat/form.py b/webcompat/form.py index 320720d74..f403f2e68 100644 --- a/webcompat/form.py +++ b/webcompat/form.py @@ -173,22 +173,20 @@ class PrefixedRadioField(RadioField): - """Prefix radio field label with an image.""" + """Prefix radio field label with an image. + + This renders the radio elements with a specific html markup. + """ def __init__(self, *args, **kwargs): prefixed_choices = kwargs.pop('choices') - template = '
{text}' choices = [] - - css_class = 'icon-container' for slug, img, text in prefixed_choices: - filename = 'img/svg/icons/{img}'.format(img=img) + filename = f'img/svg/icons/{img}' src = url_for('static', filename=filename) - label = Markup(template.format( - src=src, css_class=css_class, text=text) - ) + t = f'
{text}' + label = Markup(t) choice = (slug, label) choices.append(choice) - kwargs['choices'] = choices super().__init__(*args, **kwargs)