Пример #1
0
def index():
    '''Main view where people come to report issues.'''
    bug_form = IssueForm(request.form)
    # add browser and version to bug_form object data
    ua_header = request.headers.get('User-Agent')
    bug_form.browser.data = get_browser(ua_header)
    bug_form.os.data = get_os(ua_header)
    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)
    # Form submission.
    elif request.method == 'POST' and bug_form.validate():
        # copy the form so we can add the full UA string to it.
        form = request.form.copy()
        form['ua_header'] = ua_header
        if form.get('submit-type') == AUTH_REPORT:
            if g.user:  # If you're already authed, submit the bug.
                response = report_issue(form)
                return redirect(url_for('thanks',
                                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()
            return redirect(url_for('thanks', number=response.get('number')))
    else:
        # Validation failed, re-render the form with the errors.
        return render_template('index.html', form=bug_form)
Пример #2
0
def index():
    """Set the main view where people come to report issues."""
    push('/css/dist/webcompat.min.css', **{
        'as': 'style',
        'rel': 'preload'
    })
    push(bust_cache('/js/dist/webcompat.min.js'), **{
        'as': 'script',
        'rel': 'preload'
    })
    push('/img/svg/icons/svg-leaf_right.svg', **{
        'as': 'img',
        'rel': 'preload'
    })
    push('/img/svg/icons/svg-leaf_left.svg', **{
        'as': 'img',
        'rel': 'preload'
    })
    ua_header = request.headers.get('User-Agent')
    bug_form = get_form({'user_agent': 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 g.user:
        get_user_info()
    return render_template('index.html', form=bug_form, browser=browser_name)
Пример #3
0
def index():
    '''Main view where people come to report issues.'''
    bug_form = IssueForm(request.form)
    # add browser and version to bug_form object data
    ua_header = request.headers.get('User-Agent')
    bug_form.browser.data = get_browser(ua_header)
    bug_form.os.data = get_os(ua_header)
    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)
    # Form submission.
    elif request.method == 'POST' and bug_form.validate():
        # copy the form so we can add the full UA string to it.
        form = request.form.copy()
        form['ua_header'] = ua_header
        if form.get('submit-type') == AUTH_REPORT:
            if g.user:  # If you're already authed, submit the bug.
                response = report_issue(form)
                return redirect(
                    url_for('thanks', 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()
            return redirect(url_for('thanks', number=response.get('number')))
    else:
        # Validation failed, re-render the form with the errors.
        return render_template('index.html', form=bug_form)
Пример #4
0
def index():
    """Set the 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 g.user:
        get_user_info()
    return render_template('index.html', form=bug_form, browser=browser_name)
Пример #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 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)
Пример #7
0
def index():
    '''Main view where people come to report issues.'''
    bug_form = IssueForm()
    # add browser and version to bug_form object data
    ua_header = request.headers.get('User-Agent')
    bug_form.browser.data = get_browser(ua_header)
    bug_form.os.data = get_os(ua_header)
    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)
Пример #8
0
def index():
    '''Main view where people come to report issues.'''
    bug_form = IssueForm()
    # add browser and version to bug_form object data
    ua_header = request.headers.get('User-Agent')
    bug_form.browser.data = get_browser(ua_header)
    bug_form.os.data = get_os(ua_header)
    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)