Example #1
0
def create_user(gh_user):
    "Create a User from a `github.NamedUser`."
    try:
        return User.objects.get(login=gh_user.login)
    except User.DoesNotExist:
        user = User(login=gh_user.login,
                    name=gh_user.name,
                    avatar_url='//www.gravatar.com/avatar/%s?s=52' % gh_user.gravatar_id,
                    assigned_issues_url='https://github.com/%s/issues/assigned/%s' % \
                        (config.GITHUB_REPO, gh_user.login))
        return user.save()
Example #2
0
def create_user(gh_user):
    "Create a User from a `github.NamedUser`."
    try:
        return User.objects.get(login=gh_user.login)
    except User.DoesNotExist:
        user = User(login=gh_user.login,
                    name=gh_user.name,
                    avatar_url='//www.gravatar.com/avatar/%s?s=52' % gh_user.gravatar_id,
                    assigned_issues_url='https://github.com/%s/issues/assigned/%s' % \
                        (config.GITHUB_REPO, gh_user.login))
        return user.save()
Example #3
0
def create_user(jira_user):
    "Creates a `githubsurvivor.models.User` from a `jira.resources.User`."
    try:
        return User.objects.get(login=jira_user.name)
    except User.DoesNotExist:
        user = User(login=jira_user.name,
                    name=jira_user.displayName,
                    email=jira_user.emailAddress,
                    avatar_url=jira_user.avatarUrls.__dict__['48x48'],
                    # FIXME: is it possible to generate this?
                    #assigned_issues_url=
                    )
        return user.save()
Example #4
0
def sync(types, verbose=False):

    importer = issue_importer()

    if 'users' in types:
        if verbose: print 'Synchronising users...'
        User.drop_collection()
        importer.import_users(verbose)

    if 'issues' in types:
        if verbose: print 'Synchronising issues...'
        Issue.drop_collection()
        importer.import_issues(verbose)
Example #5
0
def create_user(gh_user, verbose):
    "Create a User from a `github.NamedUser`."
    if gh_user['login'] in config.GITHUB_IGNORE_LOGINS:
        return

    try:
        return User.objects.get(login=gh_user['login'])
    except User.DoesNotExist:
        user = User(login=gh_user['login'],
                    name=gh_user['name'],
                    avatar_url='//www.gravatar.com/avatar/%s?s=52' % gh_user['gravatar_id'],
                    assigned_issues_url='https://github.com/%s/issues/assigned/%s' % \
                        (config.GITHUB_REPO, gh_user['login']))
        if verbose and user: print 'created user: %s' % user.login
        return user.save()