예제 #1
0
def get_user_issues(username):
    '''Return 8 issues in the repo reported by `username` (the creator
    in the JSON response.'''
    user_issues_uri = 'repos/{0}?creator={1}&state=all'.format(
        REPO_URI, username)
    issues = github.get(user_issues_uri)
    return add_status_class(issues)[0:8]
예제 #2
0
def get_user_issues(username):
    '''Return 8 issues in the repo reported by `username` (the creator
    in the JSON response.'''
    user_issues_uri = 'repos/{0}?creator={1}&state=all'.format(REPO_URI,
                                                               username)
    issues = github.get(user_issues_uri)
    return add_status_class(issues)[0:8]
예제 #3
0
def user_issues():
    '''API endpoint to return issues filed by the logged in user. Cached
    for five minutes.'''
    get_user_info()
    issues = github.get('repos/{0}?creator={1}&state=all'.format(
        REPO_URI, session['username']))
    return json.dumps(issues)
예제 #4
0
def proxy_issues():
    '''API endpoint to list all issues from GitHub. Cached for 5 minutes.'''
    if g.user:
        issues = github.get('repos/{0}'.format(REPO_URI))
    else:
        issues = proxy_request('get')
    return json.dumps(issues)
예제 #5
0
def get_user_info():
    '''Grab the username and avatar URL from GitHub.'''
    if session.get('username') and session.get('avatar_url'):
        return
    else:
        gh_user = github.get('user')
        session['username'] = gh_user.get('login')
        session['avatar_url'] = gh_user.get('avatar_url')
예제 #6
0
def get_user_info():
    '''Grab the username and avatar URL from GitHub.'''
    if session.get('username') and session.get('avatar_url'):
        return
    else:
        gh_user = github.get('user')
        session['username'] = gh_user.get('login')
        session['avatar_url'] = gh_user.get('avatar_url')
예제 #7
0
def get_user_info():
    """Grab the username and avatar URL from GitHub."""
    if session.get("username") and session.get("avatar_url"):
        return
    else:
        gh_user = github.get("user")
        session["username"] = gh_user.get("login")
        session["avatar_url"] = gh_user.get("avatar_url")
예제 #8
0
def proxy_issues():
    '''API endpoint to list all issues from GitHub.

    Cached for 5 minutes.
    '''
    if g.user:
        issues = github.get('repos/{0}'.format(REPO_URI))
    else:
        issues = proxy_request('get')
    return json.dumps(issues)
예제 #9
0
def new_issue():
    form = IssueForm(request.form)
    if request.method == 'GET':
        if g.user:
            user_info = github.get('user')
            return render_template('new_issue.html', form=form)
        else:
            return redirect(url_for('login'))
    elif request.method == 'POST' and form.validate():
        r = github.post('repos/' + app.config['ISSUES_REPO_URI'],
                        build_formdata(request.form))
        issue_number = r.get('number')
        return redirect(url_for('show_issue', number=issue_number))
    else:
        # Validation failed, re-render the form with the errors.
        return render_template('new_issue.html', form=form)
예제 #10
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
    bug_form.browser.data = get_browser_name(request.headers.get('User-Agent'))
    bug_form.version.data = get_browser_version(
        request.headers.get('User-Agent'))
    # GET means you want to file a report.
    if request.method == 'GET':
        if g.user:
            try:
                user = User.query.get(session['user_id'])
                if user.avatar_url != '' and user.username != '':
                    session['username'] = user.username
                    session['avatar_url'] = user.avatar_url
                else:
                    gh_user = github.get('user')
                    user.username = gh_user.get('login')
                    user.avatar_url = gh_user.get('avatar_url')
                    db_session.commit()
                    session['username'] = user.username
                    session['avatar_url'] = user.avatar_url
            except ConnectionError, e:
                print e
            user_issues = get_user_issues(session['username'])
            contact_ready = get_contact_ready()
            needs_diagnosis = get_needs_diagnosis()
        else:
            user_issues = []
            contact_ready = proxy_get_contact_ready()
            needs_diagnosis = proxy_get_needs_diagnosis()
        return render_template('index.html',
                               form=bug_form,
                               user_issues=user_issues,
                               contact_ready=contact_ready,
                               needs_diagnosis=needs_diagnosis)
예제 #11
0
def get_needs_diagnosis():
    '''Return the first 4 issues that need diagnosis.'''
    issues = github.get('repos/{0}'.format(REPO_URI))
    return filter_needs_diagnosis(issues)[0:4]
예제 #12
0
def get_contact_ready():
    '''Return all issues with a "contactready" label.'''
    uri = 'repos/{0}?labels=contactready'.format(REPO_URI)
    issues = github.get(uri)
    return issues[0:4]
예제 #13
0
def get_issue(number):
    '''Return a single issue by issue number.'''
    issue_uri = 'repos/{0}/{1}'.format(REPO_URI, number)
    issue = github.get(issue_uri)
    return issue
예제 #14
0
def get_needs_diagnosis():
    '''Return the first 4 issues that need diagnosis.'''
    issues = github.get('repos/{0}'.format(REPO_URI))
    return filter_needs_diagnosis(issues)[0:4]
예제 #15
0
def get_contact_ready():
    '''Return all issues with a "contactready" label.'''
    uri = 'repos/{0}?labels=contactready'.format(REPO_URI)
    issues = github.get(uri)
    return issues[0:4]
예제 #16
0
def get_issue(number):
    '''Return a single issue by issue number.'''
    issue_uri = 'repos/{0}/{1}'.format(REPO_URI, number)
    issue = github.get(issue_uri)
    return issue