예제 #1
0
def get_or_create_contributor(login):
    """Return a contributor object."""
    try:
        return Contributor.objects.get(login=login)
    except Contributor.DoesNotExist:
        user_data = github.get_user_data(login, session)
        contributor, _ = misc.get_or_create_record(Contributor, user_data)
        return contributor
예제 #2
0
def get_contributor_data(login, session=None):
    """Get contributor data from database or GitHub."""
    Contributor = apps.get_model('contributors.Contributor')  # noqa: N806
    try:
        user = Contributor.objects.get(login=login)
    except Contributor.DoesNotExist:
        return github.get_user_data(login, session)
    return {
        'id': user.id,
        'name': user.name,
        'html_url': user.html_url,
        'login': user.login,
        'avatar_url': user.avatar_url,
    }
예제 #3
0
def get_or_create_contributor(login):
    """Return a contributor object."""
    user_data = github.get_user_data(login)
    contributor, _ = misc.get_or_create_record(Contributor, user_data)
    return contributor