Пример #1
0
def create_issue():
    """Creates a new issue.

    GET will return an HTML response for reporting issues
    POST will create a new issue
    """
    if request.method == 'GET':
        bug_form = get_form(request.headers.get('User-Agent'))
        if g.user:
            get_user_info()
        if request.args.get('src'):
            session['src'] = request.args.get('src')
        return render_template('new-issue.html', form=bug_form)
    # copy the form so we can add the full UA string to it.
    form = request.form.copy()
    # see https://github.com/webcompat/webcompat.com/issues/1141
    # see https://github.com/webcompat/webcompat.com/issues/1237
    spamlist = ['qiangpiaoruanjian', 'cityweb.de']
    for spam in spamlist:
        if spam in form.get('url'):
            msg = (u'Anonymous reporting for domain {0} '
                   'is temporarily disabled. Please contact '
                   '[email protected] '
                   'for more details.').format(spam)
            flash(msg, 'notimeout')
            return redirect(url_for('index'))
    form['ua_header'] = request.headers.get('User-Agent')
    # Currently we support either a src GET param, or X-Reported-With header
    # to track where the report originated from.
    # See https://github.com/webcompat/webcompat.com/issues/1254 to track
    # supporting only the src param
    if session.get('src'):
        form['reported_with'] = session.pop('src')
    else:
        form['reported_with'] = request.headers.get('X-Reported-With', 'web')
    # Logging the ip and url for investigation
    log = app.logger
    log.setLevel(logging.INFO)
    log.info('{ip} {url}'.format(ip=request.remote_addr, url=form['url']))
    # form submission for 3 scenarios: authed, to be authed, anonymous
    if form.get('submit-type') == AUTH_REPORT:
        if g.user:  # If you're already authed, submit the bug.
            response = report_issue(form)
            session['show_thanks'] = True
            return redirect(
                url_for('show_issue', number=response.get('number')))
        else:  # Stash form data into session, go do GitHub auth
            session['form_data'] = form
            return redirect(url_for('login'))
    elif form.get('submit-type') == PROXY_REPORT:
        response = report_issue(form, proxy=True).json()
        session['show_thanks'] = True
        return redirect(url_for('show_issue', number=response.get('number')))
Пример #2
0
def create_issue():
    """Creates a new issue.

    GET will return an HTML response for reporting issues
    POST will create a new issue
    """
    if request.method == 'GET':
        bug_form = get_form(request.headers.get('User-Agent'))
        if g.user:
            get_user_info()
        if request.args.get('src'):
            session['src'] = request.args.get('src')
        return render_template('new-issue.html', form=bug_form)
    # copy the form so we can add the full UA string to it.
    form = request.form.copy()
    # see https://github.com/webcompat/webcompat.com/issues/1141
    # see https://github.com/webcompat/webcompat.com/issues/1237
    spamlist = ['qiangpiaoruanjian', 'cityweb.de']
    for spam in spamlist:
        if spam in form.get('url'):
            msg = (u'Anonymous reporting for domain {0} '
                   'is temporarily disabled. Please contact '
                   '[email protected] '
                   'for more details.').format(spam)
            flash(msg, 'notimeout')
            return redirect(url_for('index'))
    form['ua_header'] = request.headers.get('User-Agent')
    form['reported_with'] = session.pop('src', 'web')
    # Logging the ip and url for investigation
    log = app.logger
    log.setLevel(logging.INFO)
    log.info('{ip} {url}'.format(ip=request.remote_addr, url=form['url']))
    # form submission for 3 scenarios: authed, to be authed, anonymous
    if form.get('submit-type') == AUTH_REPORT:
        if g.user:  # If you're already authed, submit the bug.
            response = report_issue(form)
            session['show_thanks'] = True
            return redirect(url_for('show_issue',
                                    number=response.get('number')))
        else:  # Stash form data into session, go do GitHub auth
            session['form_data'] = form
            return redirect(url_for('login'))
    elif form.get('submit-type') == PROXY_REPORT:
        response = report_issue(form, proxy=True).json()
        session['show_thanks'] = True
        return redirect(url_for('show_issue', number=response.get('number')))
Пример #3
0
def index():
    """Main view where people come to report issues."""
    ua_header = request.headers.get("User-Agent")
    bug_form = get_form(ua_header)
    # browser_name is used in topbar.html to show the right add-on link
    browser_name = get_browser_name(ua_header)
    # GET means you want to file a report.
    if request.method == "GET":
        if g.user:
            get_user_info()
        return render_template("index.html", form=bug_form, browser=browser_name)
    # Validate, then create issue.
    elif bug_form.validate_on_submit():
        return create_issue()

    else:
        # Validation failed, re-render the form with the errors.
        return render_template("index.html", form=bug_form, browser=browser_name)
Пример #4
0
def create_issue():
    """Creates a new issue.

    GET will return an HTML response for reporting issues
    POST will create a new issue
    """
    if request.method == "GET":
        bug_form = get_form(request.headers.get("User-Agent"))
        if g.user:
            get_user_info()
        return render_template("new-issue.html", form=bug_form)
    # copy the form so we can add the full UA string to it.
    form = request.form.copy()
    # see https://github.com/webcompat/webcompat.com/issues/1141
    spamlist = ["qiangpiaoruanjian"]
    for spam in spamlist:
        if spam in form.get("url"):
            msg = (
                u"Anonymous reporting for qiangpiaoruanjian.cn "
                "is temporarily disabled. Please see "
                "https://github.com/webcompat/webcompat.com/issues/1141 "
                "for more details."
            )
            flash(msg, "notimeout")
            return redirect(url_for("index"))
    form["ua_header"] = request.headers.get("User-Agent")
    # Store where the report originated from
    form["reported_with"] = request.headers.get("X-Reported-With", "web")
    # Logging the ip and url for investigation
    log = app.logger
    log.setLevel(logging.INFO)
    log.info("{ip} {url}".format(ip=request.remote_addr, url=form["url"]))
    # form submission for 3 scenarios: authed, to be authed, anonymous
    if form.get("submit-type") == AUTH_REPORT:
        if g.user:  # If you're already authed, submit the bug.
            response = report_issue(form)
            return thanks_page(request, response)
        else:  # Stash form data into session, go do GitHub auth
            session["form_data"] = form
            return redirect(url_for("login"))
    elif form.get("submit-type") == PROXY_REPORT:
        response = report_issue(form, proxy=True).json()
        return thanks_page(request, response)
Пример #5
0
def index():
    '''Main view where people come to report issues.'''
    ua_header = request.headers.get('User-Agent')
    bug_form = get_form(ua_header)
    # browser_name is used in topbar.html to show the right add-on link
    browser_name = get_browser_name(ua_header)
    # GET means you want to file a report.
    if request.method == 'GET':
        if g.user:
            get_user_info()
        return render_template('index.html', form=bug_form,
                               browser=browser_name)
    # Validate, then create issue.
    elif bug_form.validate_on_submit():
        return create_issue()

    else:
        # Validation failed, re-render the form with the errors.
        return render_template('index.html', form=bug_form,
                               browser=browser_name)
Пример #6
0
def create_issue():
    """Creates a new issue.

    GET will return an HTML response for reporting issues
    POST will create a new issue
    """
    if request.method == 'GET':
        bug_form = get_form(request.headers.get('User-Agent'))
        if g.user:
            get_user_info()
        return render_template('new-issue.html', form=bug_form)
    # copy the form so we can add the full UA string to it.
    form = request.form.copy()
    # see https://github.com/webcompat/webcompat.com/issues/1141
    spamlist = ['qiangpiaoruanjian']
    for spam in spamlist:
        if spam in form.get('url'):
            msg = (u'Anonymous reporting for qiangpiaoruanjian.cn '
                   'is temporarily disabled. Please see '
                   'https://github.com/webcompat/webcompat.com/issues/1141 '
                   'for more details.')
            flash(msg, 'notimeout')
            return redirect(url_for('index'))
    form['ua_header'] = request.headers.get('User-Agent')
    # Store where the report originated from
    form['reported_with'] = request.headers.get('X-Reported-With', 'web')
    # Logging the ip and url for investigation
    log = app.logger
    log.setLevel(logging.INFO)
    log.info('{ip} {url}'.format(ip=request.remote_addr, url=form['url']))
    # form submission for 3 scenarios: authed, to be authed, anonymous
    if form.get('submit-type') == AUTH_REPORT:
        if g.user:  # If you're already authed, submit the bug.
            response = report_issue(form)
            return thanks_page(request, response)
        else:  # Stash form data into session, go do GitHub auth
            session['form_data'] = form
            return redirect(url_for('login'))
    elif form.get('submit-type') == PROXY_REPORT:
        response = report_issue(form, proxy=True).json()
        return thanks_page(request, response)