def project_import_github(request): """Show form that prefills import form with data from GitHub""" github_connected = oauth_utils.import_github( user=request.user, sync=False) 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, }, context_instance=RequestContext(request) )
def project_import_github(request): '''Show form that prefills import form with data from GitHub''' github_connected = oauth_utils.import_github( user=request.user, sync=False) 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, }, context_instance=RequestContext(request) )
def handle(self, *args, **options): if len(args): for slug in args: import_github(user=User.objects.get(username=slug), sync=True)
def test_import_github_with_no_token(self): github_connected = import_github(self.user, sync=True) self.assertEqual(github_connected, False)