コード例 #1
0
ファイル: private.py プロジェクト: dpgeorge/readthedocs.org
def project_import_github(request, sync=False):
    """
    Integrate with GitHub to pull repos from there.

    """

    github_connected = oauth_utils.import_github(user=request.user, sync=sync)

    repos = GithubProject.objects.filter(users__in=[request.user])

    # Find existing projects that match a repo url
    for repo in repos:
        ghetto_repo = repo.git_url.replace('git://', '').replace('.git', '')
        projects = Project.objects.filter(repo__endswith=ghetto_repo) | Project.objects.filter(repo__endswith=ghetto_repo + '.git')
        if projects:
            repo.matches = [project.slug for project in projects]
        else:
            repo.matches = []

    return render_to_response(
        'projects/project_import_github.html',
        {
            'repos': repos,
            'github_connected': github_connected,
            'sync': sync,
        },
        context_instance=RequestContext(request)
    )
コード例 #2
0
def project_import_github(request, sync=False):
    """
    Integrate with GitHub to pull repos from there.

    """

    github_connected = oauth_utils.import_github(user=request.user, sync=sync)

    repos = GithubProject.objects.filter(users__in=[request.user])

    # Find existing projects that match a repo url
    for repo in repos:
        ghetto_repo = repo.git_url.replace('git://', '').replace('.git', '')
        projects = Project.objects.filter(
            repo__endswith=ghetto_repo) | Project.objects.filter(
                repo__endswith=ghetto_repo + '.git')
        if projects:
            repo.matches = [project.slug for project in projects]
        else:
            repo.matches = []

    return render_to_response('projects/project_import_github.html', {
        'repos': repos,
        'github_connected': github_connected,
        'sync': sync,
    },
                              context_instance=RequestContext(request))
コード例 #3
0
ファイル: private.py プロジェクト: 1and1/readthedocs.org
def project_import_github(request, sync=False):
    '''Show form that prefills import form with data from GitHub'''
    github_connected = oauth_utils.import_github(user=request.user, sync=sync)
    repos = GithubProject.objects.filter(users__in=[request.user])

    # Find existing projects that match a repo url
    for repo in repos:
        ghetto_repo = repo.git_url.replace('git://', '').replace('.git', '')
        projects = (Project
                    .objects
                    .public(request.user)
                    .filter(Q(repo__endswith=ghetto_repo) |
                            Q(repo__endswith=ghetto_repo + '.git')))
        if projects:
            repo.matches = [project.slug for project in projects]
        else:
            repo.matches = []

    return render_to_response(
        'projects/project_import_github.html',
        {
            'repos': repos,
            'github_connected': github_connected,
            'sync': sync,
        },
        context_instance=RequestContext(request)
    )
コード例 #4
0
def project_import_github(request, sync=False):
    '''Show form that prefills import form with data from GitHub'''
    github_connected = oauth_utils.import_github(user=request.user, sync=sync)
    repos = GithubProject.objects.filter(users__in=[request.user])

    # Find existing projects that match a repo url
    for repo in repos:
        ghetto_repo = repo.git_url.replace('git://', '').replace('.git', '')
        projects = (Project.objects.public(request.user).filter(
            Q(repo__endswith=ghetto_repo)
            | Q(repo__endswith=ghetto_repo + '.git')))
        if projects:
            repo.matches = [project.slug for project in projects]
        else:
            repo.matches = []

    return render_to_response('projects/project_import_github.html', {
        'repos': repos,
        'github_connected': github_connected,
        'sync': sync,
    },
                              context_instance=RequestContext(request))
コード例 #5
0
ファイル: test_oauth.py プロジェクト: ljc42/readthedocs.org
 def test_import_github_with_no_token(self):
     github_connected = import_github(self.user, sync=True)
     self.assertEqual(github_connected, False)
コード例 #6
0
ファイル: test_oauth.py プロジェクト: 1and1/readthedocs.org
 def test_import_github_with_no_token(self):
     github_connected = import_github(self.user, sync=True)
     self.assertEqual(github_connected, False)
コード例 #7
0
 def handle(self, *args, **options):
     if len(args):
         for slug in args:
             import_github(user=User.objects.get(username=slug), sync=True)