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) )
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))
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) )
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))
def test_import_github_with_no_token(self): github_connected = import_github(self.user, sync=True) self.assertEqual(github_connected, False)
def handle(self, *args, **options): if len(args): for slug in args: import_github(user=User.objects.get(username=slug), sync=True)