コード例 #1
0
ファイル: decorators.py プロジェクト: nexus-lab/ezsetup
    def decorated_function(*args, **kwargs):
        if not hasattr(g, 'user') or g.user is None:
            token = request.headers['Authorization']
            email = request.headers['Email']
            valueStr = redis_token_db.get(email)
            if valueStr is None:
                abort(
                    make_response(
                        jsonify(message="Unauthenticated request: no email"),
                        401))
            value = json.loads(valueStr)
            if token != value['token']:
                abort(
                    make_response(
                        jsonify(
                            message="Unauthenticated request: wrong password"),
                        401))
            else:
                g.user = value

                # This is an additional, application-specific step. You can
                # remove it in your application
                get_user_info()

        return f(*args, **kwargs)
コード例 #2
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)
コード例 #3
0
ファイル: views.py プロジェクト: vladikoff/webcompat.com
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
ファイル: views.py プロジェクト: sirinartk/webcompat.com
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)
コード例 #5
0
ファイル: views.py プロジェクト: tagawa/webcompat.com
def show_issue(number):
    '''Route to display a single issue.'''
    if g.user:
        get_user_info()
    if session.get('show_thanks'):
        flash(number, 'thanks')
        session.pop('show_thanks')
    return render_template('issue.html', number=number)
コード例 #6
0
def show_issue(number):
    """Route to display a single issue."""
    if g.user:
        get_user_info()
    if session.get('show_thanks'):
        flash(number, 'thanks')
        session.pop('show_thanks')
    return render_template('issue.html', number=number)
コード例 #7
0
ファイル: views.py プロジェクト: haseebgit/webcompat.com
def thanks(number):
    issue = number
    uri = u"https://webcompat.com/issues/{0}".format(number)
    text = u"I just filed a bug on the internet: "
    encoded_issue = urllib.quote(uri.encode("utf-8"))
    encoded_text = urllib.quote(text.encode("utf-8"))
    if g.user:
        get_user_info()
    return render_template("thanks.html", number=issue, encoded_issue=encoded_issue, encoded_text=encoded_text)
コード例 #8
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)
コード例 #9
0
def show_issue(number):
    '''Route to display a single issue.'''
    if g.user:
        get_user_info()
    if session.get('show_thanks'):
        flash(number, 'thanks')
        session.pop('show_thanks')
    content = render_template('issue.html', number=number)
    response = make_response(content)
    return response
コード例 #10
0
def dashboard_triage():
    """Route to handle dashboard triage."""
    if g.user:
        get_user_info()
    params = {'per_page': 100, 'sort': 'created', 'direction': 'asc'}
    needstriage_issues = get_milestone_list('needstriage', params)
    needstriage_list, stats = filter_needstriage(needstriage_issues)
    return render_template('dashboard/triage.html',
                           needstriage_list=needstriage_list,
                           stats=stats)
コード例 #11
0
ファイル: views.py プロジェクト: amune/bug.amune.org
def thanks(number):
    issue = number
    uri = u"http://webcompat.com/issues/{0}".format(number)
    text = u"I just filed a bug on the internet: "
    encoded_issue = urllib.quote(uri.encode("utf-8"))
    encoded_text = urllib.quote(text.encode("utf-8"))
    if g.user:
        get_user_info()
    return render_template('thanks.html', number=issue,
                           encoded_issue=encoded_issue,
                           encoded_text=encoded_text)
コード例 #12
0
ファイル: views.py プロジェクト: ioana-chiorean/webcompat.com
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')))
コード例 #13
0
ファイル: views.py プロジェクト: theyork123/webcompat.com
def show_issues():
    """Route to display global issues view."""
    push('/css/dist/webcompat.min.css', **{'as': 'style', 'rel': 'preload'})
    push(bust_cache('/js/dist/webcompat.min.js'), **{
        'as': 'script',
        'rel': 'preload'
    })
    push(bust_cache('/js/dist/issues.min.js'), **{
        'as': 'script',
        'rel': 'preload'
    })
    if g.user:
        get_user_info()
    categories = app.config['CATEGORIES']
    return render_template('list-issue.html', categories=categories)
コード例 #14
0
ファイル: views.py プロジェクト: theyork123/webcompat.com
def show_issue(number):
    """Route to display a single issue."""
    push('/css/dist/webcompat.min.css', **{'as': 'style', 'rel': 'preload'})
    push(bust_cache('/js/dist/webcompat.min.js'), **{
        'as': 'script',
        'rel': 'preload'
    })
    push(bust_cache('/js/dist/issues.min.js'), **{
        'as': 'script',
        'rel': 'preload'
    })
    if g.user:
        get_user_info()
    if session.get('show_thanks'):
        flash(number, 'thanks')
        session.pop('show_thanks')
    return render_template('issue.html', number=number)
コード例 #15
0
ファイル: views.py プロジェクト: tagawa/webcompat.com
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')))
コード例 #16
0
ファイル: views.py プロジェクト: haseebgit/webcompat.com
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)
コード例 #17
0
ファイル: views.py プロジェクト: webcompat/webcompat.com
def show_issues():
    """Route to display global issues view."""
    push('/css/dist/webcompat.min.css', **{
        'as': 'style',
        'rel': 'preload'
    })
    push(bust_cache('/js/dist/webcompat.min.js'), **{
        'as': 'script',
        'rel': 'preload'
    })
    push(bust_cache('/js/dist/issues.min.js'), **{
        'as': 'script',
        'rel': 'preload'
    })
    if g.user:
        get_user_info()
    categories = app.config['CATEGORIES']
    return render_template('list-issue.html', categories=categories)
コード例 #18
0
ファイル: views.py プロジェクト: haseebgit/webcompat.com
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)
コード例 #19
0
ファイル: views.py プロジェクト: haseebgit/webcompat.com
def show_user_page(username):
    """The logic for this route is as follows:

    (this dupes some of the functionality of /me, but allows directly visiting
    this endpoint via a bookmark)

    If the user is not logged in, send back a 401.
    Make sure we have username and avatar details from Github
    If the username matches, render the template as expected.
    If it doesn't match, abort with 403 until we support looking at
    *other* users activity.
    """
    if not g.user:
        abort(401)
    get_user_info()
    if username == session["username"]:
        return render_template("user-activity.html", user=username)
    else:
        abort(403)
コード例 #20
0
def show_user_page(username):
    """Set the route for user activity.

    (this dupes some of the functionality of /me, but allows directly visiting
    this endpoint via a bookmark)

    If the user is not logged in, send back a 401.
    Make sure we have username and avatar details from Github
    If the username matches, render the template as expected.
    If it doesn't match, abort with 403 until we support looking at
    *other* users activity.
    """
    if not g.user:
        abort(401)
    get_user_info()
    if username == session['username']:
        return render_template('user-activity.html', user=username)
    else:
        abort(403)
コード例 #21
0
ファイル: views.py プロジェクト: webcompat/webcompat.com
def show_issue(number):
    """Route to display a single issue."""
    push('/css/dist/webcompat.min.css', **{
        'as': 'style',
        'rel': 'preload'
    })
    push(bust_cache('/js/dist/webcompat.min.js'), **{
        'as': 'script',
        'rel': 'preload'
    })
    push(bust_cache('/js/dist/issues.min.js'), **{
        'as': 'script',
        'rel': 'preload'
    })
    if g.user:
        get_user_info()
    if session.get('show_thanks'):
        flash(number, 'thanks')
        session.pop('show_thanks')
    return render_template('issue.html', number=number)
コード例 #22
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)
コード例 #23
0
ファイル: views.py プロジェクト: kangashley/webcompat.com
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)
コード例 #24
0
ファイル: views.py プロジェクト: vsham20/webcompat.com
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)
コード例 #25
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)
コード例 #26
0
ファイル: project.py プロジェクト: em-torres/OAuth2.0
def show_menu(restaurant_id):
    restaurant = session.query(Restaurant).filter_by(id=restaurant_id).one()
    creator = get_user_info(restaurant.user_id)
    items = session.query(MenuItem).filter_by(
        restaurant_id=restaurant_id).all()
    can_edit = True
    if creator is not None and 'username' in login_session:
        can_edit = creator.id != login_session['user_id']
    if 'username' not in login_session or can_edit:
        return render_template('publicmenu.html',
                               items=items,
                               restaurant=restaurant,
                               creator=creator)
    else:
        return render_template('menu.html',
                               items=items,
                               restaurant=restaurant,
                               creator=creator)
コード例 #27
0
def contributors_bug_diagnosis():
    """Route to display contributors/diagnose-bug page."""
    if g.user:
        get_user_info()
    return render_template('contributors/diagnose-bug.html')
コード例 #28
0
def contributors():
    """Route to display contributors page."""
    if g.user:
        get_user_info()
    return render_template('contributors.html')
コード例 #29
0
def privacy():
    """Route to display privacy page."""
    if g.user:
        get_user_info()
    return render_template('privacy.html')
コード例 #30
0
ファイル: views.py プロジェクト: webcompat/webcompat.com
def contributors_other_tools():
    """Route to display contributors/build-tools page."""
    if g.user:
        get_user_info()
    return render_template('contributors/build-tools.html')
コード例 #31
0
ファイル: views.py プロジェクト: webcompat/webcompat.com
def contributors_bug_outreach():
    """Route to display contributors/site-outreach page."""
    if g.user:
        get_user_info()
    return render_template('contributors/site-outreach.html')
コード例 #32
0
def show_issues():
    """Route to display global issues view."""
    if g.user:
        get_user_info()
    categories = app.config['CATEGORIES']
    return render_template('list-issue.html', categories=categories)
コード例 #33
0
ファイル: views.py プロジェクト: uemarica/webcompat.com
def create_issue():
    """Create a new issue or prefill a form for submission.

    * HTTP GET with (optional) parameters
      * create a form with prefilled data.
      * parameters:
        * url: URL of the Web site
        * src: source of the request (web, addon, etc.)
        * label: controled list of labels
    * HTTP POST with a JSON payload
      * create a form with prefilled data
      * content-type is application/json
      * json may include:
        * title
        * User agent string
        * OS identification
        * labels list
        * type of bugs
        * short summary
        * full description
        * tested in another browser
        * body
    * HTTP POST with an attached form
      * submit a form to GitHub to create a new issue
      * form submit type:
        * authenticated: Github authentification
        * anonymous: handled by webcompat-bot

    Any deceptive requests will be ended as a 400.
    See https://tools.ietf.org/html/rfc7231#section-6.5.1
    """
    # Starting a logger
    log = app.logger
    log.setLevel(logging.INFO)
    if g.user:
        get_user_info()
    # We define which type of requests we are dealing with.
    request_type = form_type(request)
    # Form Prefill section
    if request_type == 'prefill':
        form_data = prepare_form(request)
        bug_form = get_form(form_data)
        session['extra_labels'] = form_data['extra_labels']
        return render_template('new-issue.html', form=bug_form)
    # Issue Creation section
    elif request_type == 'create':
        # Check if there is a form
        if not request.form:
            log.info('POST request without form.')
            abort(400)
        # Adding parameters to the form
        form = request.form.copy()
        extra_labels = session.pop('extra_labels', None)
        if extra_labels:
            form['extra_labels'] = extra_labels
        # Logging the ip and url for investigation
        log.info('{ip} {url}'.format(
            ip=request.remote_addr,
            url=form['url'].encode('utf-8')))
        # Checking blacklisted domains
        if is_blacklisted_domain(form['url']):
            msg = (u'Anonymous reporting for domain {0} '
                   'is temporarily disabled. Please contact '
                   '[email protected] '
                   'for more details.').format(form['url'])
            flash(msg, 'notimeout')
            return redirect(url_for('index'))
        # Check if the form is valid
        if not is_valid_issue_form(form):
            abort(400)
        # Anonymous reporting
        if form.get('submit_type') == PROXY_REPORT:
            json_response = report_issue(form, proxy=True)
            session['show_thanks'] = True
            return redirect(
                url_for('show_issue', number=json_response.get('number')))
        # Authenticated reporting
        if form.get('submit_type') == AUTH_REPORT:
            if g.user:  # If you're already authed, submit the bug.
                json_response = report_issue(form)
                session['show_thanks'] = True
                return redirect(url_for('show_issue',
                                        number=json_response.get('number')))
            else:
                # Stash form data into session, go do GitHub auth
                session['form'] = form
                return redirect(url_for('login'))
    else:
        abort(400)
コード例 #34
0
ファイル: views.py プロジェクト: webcompat/webcompat.com
def contributors_bug_reproduce():
    """Route to display contributors/reproduce-bug page."""
    if g.user:
        get_user_info()
    return render_template('contributors/reproduce-bug.html')
コード例 #35
0
ファイル: views.py プロジェクト: digideskio/webcompat.com
def show_issues():
    '''Route to display global issues view.'''
    if g.user:
        get_user_info()
    categories = app.config['CATEGORIES']
    return render_template('list-issue.html', categories=categories)
コード例 #36
0
ファイル: views.py プロジェクト: digideskio/webcompat.com
def show_issue(number):
    '''Route to display a single issue.'''
    if g.user:
        get_user_info()
    return render_template('issue.html', number=number)
コード例 #37
0
ファイル: views.py プロジェクト: digideskio/webcompat.com
def contributors():
    '''Route to display contributors page.'''
    if g.user:
        get_user_info()
    return render_template('contributors.html')
コード例 #38
0
ファイル: views.py プロジェクト: digideskio/webcompat.com
def privacy():
    '''Route to display privacy page.'''
    if g.user:
        get_user_info()
    return render_template('privacy.html')
コード例 #39
0
def contributors_other_tools():
    """Route to display contributors/build-tools page."""
    if g.user:
        get_user_info()
    return render_template('contributors/build-tools.html')
コード例 #40
0
ファイル: views.py プロジェクト: digideskio/webcompat.com
def about():
    '''Route to display about page.'''
    if g.user:
        get_user_info()
    return render_template('about.html')
コード例 #41
0
ファイル: views.py プロジェクト: haseebgit/webcompat.com
def show_issues():
    """Route to display global issues view."""
    if g.user:
        get_user_info()
    categories = app.config["CATEGORIES"]
    return render_template("list-issue.html", categories=categories)
コード例 #42
0
ファイル: views.py プロジェクト: vladikoff/webcompat.com
def show_issues():
    '''Route to display global issues view.'''
    if g.user:
        get_user_info()
    return render_template('issue-list.html')
コード例 #43
0
ファイル: views.py プロジェクト: haseebgit/webcompat.com
def show_issue(number):
    """Route to display a single issue."""
    if g.user:
        get_user_info()
    return render_template("issue.html", number=number)
コード例 #44
0
def create_issue():
    """Create 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()
        # Note: `src` and `label` are special GET params that can pass
        # in extra information about a bug report. They're not part of the
        # HTML <form>, so we stick them in the session cookie so they survive
        # the scenario where the user decides to do authentication, and they
        # can then be passed on to form.py
        if request.args.get('src'):
            session['src'] = request.args.get('src')
        if request.args.get('label'):
            session['label'] = request.args.getlist('label')
        return render_template('new-issue.html', form=bug_form)
    # copy the form so we can add the full UA string to it.
    if request.form:
        form = request.form.copy()
        # To be legit the form needs a couple of parameters
        # if one essential is missing, it's a bad request
        must_parameters = set([
            'url', 'problem_category', 'description', 'os', 'browser',
            'username', 'submit-type'
        ])
        if not must_parameters.issubset(form.keys()):
            abort(400)
    else:
        # https://tools.ietf.org/html/rfc7231#section-6.5.1
        abort(400)
    # see https://github.com/webcompat/webcompat.com/issues/1141
    # see https://github.com/webcompat/webcompat.com/issues/1237
    # see https://github.com/webcompat/webcompat.com/issues/1627
    spamlist = ['qiangpiaoruanjian', 'cityweb.de', 'coco.fr']
    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')
    # Reminder: label is a list, if it exists
    form['extra_labels'] = session.pop('label', None)
    # 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'].encode('utf-8')))
    # 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')))
    else:
        # if anything wrong, we assume it is a bad forged request
        abort(400)
コード例 #45
0
def contributors_other_events():
    """Route to display contributors/organize-webcompat-events page."""
    if g.user:
        get_user_info()
    return render_template('contributors/organize-webcompat-events.html')
コード例 #46
0
def me_redirect():
    """Set a redirect to /activity/<username>, for logged in users."""
    if not g.user:
        abort(401)
    get_user_info()
    return redirect(url_for('show_user_page', username=session['username']))
コード例 #47
0
ファイル: views.py プロジェクト: webcompat/webcompat.com
def contributors_other_events():
    """Route to display contributors/organize-webcompat-events page."""
    if g.user:
        get_user_info()
    return render_template('contributors/organize-webcompat-events.html')
コード例 #48
0
def about():
    """Route to display about page."""
    if g.user:
        get_user_info()
    return render_template('about.html')
コード例 #49
0
ファイル: views.py プロジェクト: webcompat/webcompat.com
def contributors_bug_diagnosis():
    """Route to display contributors/diagnose-bug page."""
    if g.user:
        get_user_info()
    return render_template('contributors/diagnose-bug.html')
コード例 #50
0
def contact():
    """Route to display contact page."""
    if g.user:
        get_user_info()
    return render_template('contact.html')
コード例 #51
0
ファイル: views.py プロジェクト: haseebgit/webcompat.com
def about():
    """Route to display about page."""
    if g.user:
        get_user_info()
    return render_template("about.html")
コード例 #52
0
def contributors_bug_reproduce():
    """Route to display contributors/reproduce-bug page."""
    if g.user:
        get_user_info()
    return render_template('contributors/reproduce-bug.html')
コード例 #53
0
ファイル: views.py プロジェクト: haseebgit/webcompat.com
def privacy():
    """Route to display privacy page."""
    if g.user:
        get_user_info()
    return render_template("privacy.html")
コード例 #54
0
def contributors_bug_outreach():
    """Route to display contributors/site-outreach page."""
    if g.user:
        get_user_info()
    return render_template('contributors/site-outreach.html')
コード例 #55
0
ファイル: views.py プロジェクト: haseebgit/webcompat.com
def contributors():
    """Route to display contributors page."""
    if g.user:
        get_user_info()
    return render_template("contributors.html")
コード例 #56
0
def contributors_other_research():
    """Route to display contributors/web-platform-research page."""
    if g.user:
        get_user_info()
    return render_template('contributors/web-platform-research.html')
コード例 #57
0
ファイル: views.py プロジェクト: digideskio/webcompat.com
def me_redirect():
    '''This route redirects to /activity/<username>, for logged in users.'''
    if not g.user:
        abort(401)
    get_user_info()
    return redirect(url_for('show_user_page', username=session['username']))
コード例 #58
0
ファイル: views.py プロジェクト: haseebgit/webcompat.com
def me_redirect():
    """This route redirects to /activity/<username>, for logged in users."""
    if not g.user:
        abort(401)
    get_user_info()
    return redirect(url_for("show_user_page", username=session["username"]))
コード例 #59
0
ファイル: views.py プロジェクト: webcompat/webcompat.com
def contributors_other_research():
    """Route to display contributors/web-platform-research page."""
    if g.user:
        get_user_info()
    return render_template('contributors/web-platform-research.html')