Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions webcompat/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from flask_wtf.file import FileField
from markupsafe import Markup
from wtforms import HiddenField
from wtforms import Label
from wtforms import RadioField
from wtforms import StringField
from wtforms import TextAreaField
Expand All @@ -38,8 +37,6 @@
from webcompat.helpers import get_details_list
from webcompat.helpers import is_json_object

AUTH_REPORT = 'github-auth-report'
PROXY_REPORT = 'github-proxy-report'
SCHEMES = ('http://', 'https://')
BAD_SCHEMES = ('http:/', 'https:/', 'http:', 'https:')
GITHUB_HELP = '_From [webcompat.com](https://webcompat.com/) with ❤️_'
Expand Down Expand Up @@ -176,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 = '<div class={css_class}><img src={src}/></div> {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}'
Comment thread
karlcow marked this conversation as resolved.
src = url_for('static', filename=filename)
label = Markup(template.format(
src=src, css_class=css_class, text=text)
)
t = f'<div class="icon-container"><img src="{src}"/></div> {text}'
label = Markup(t)
choice = (slug, label)
choices.append(choice)

kwargs['choices'] = choices
super().__init__(*args, **kwargs)

Expand Down
1 change: 0 additions & 1 deletion webcompat/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import requests
from ua_parser import user_agent_parser

from webcompat import api
from webcompat import app
from webcompat import github

Expand Down
6 changes: 2 additions & 4 deletions webcompat/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@
from webcompat.api.endpoints import proxy_issue
from webcompat.db import session_db
from webcompat.db import User
from webcompat.form import AUTH_REPORT
from webcompat.form import get_form
from webcompat.form import FormWizard
from webcompat.form import PROXY_REPORT
from webcompat.form import normalize_url
from webcompat.helpers import ab_active
from webcompat.helpers import ab_current_experiments
Expand Down Expand Up @@ -305,7 +303,7 @@ def create_issue():
msg = app.config['IS_DARKNET_DOMAIN'].format(form['url'])
flash(msg, 'notimeout')
return redirect(url_for('index'))
if form.get('submit_type') == PROXY_REPORT:
if form.get('submit_type') == 'github-proxy-report':
if not app.config['ANONYMOUS_REPORTING_ENABLED']:
abort(400)
# Checking blocked domains
Expand All @@ -319,7 +317,7 @@ def create_issue():
return redirect(
url_for('show_issue', number=json_response.get('number')))
# Authenticated reporting
if form.get('submit_type') == AUTH_REPORT:
if form.get('submit_type') == 'github-auth-report':
if g.user: # If you're already authed, submit the bug.
json_response = report_issue(form)
session['show_thanks'] = True
Expand Down