def done(): username = '' repo = '' if request.method == 'GET': if 'code' in request.args: code = request.args['code'] github = apiwrap.GithubAPI(debug=app.config['DEBUG']) success_repo = github.duplicate_repo(code) if success_repo: print(' ----- ALL SET!! ------ ') username = github.user.username repo = github.user.repo success_str = 'Successful Repo Duplication! Thanks!' flash(success_str,'success') return render_template('thanks.html', title='Thanks', username=username, repo=repo) danger_str = 'Failure duplicating the repo! Sorry!' flash(danger_str,'danger') return render_template('fail.html', title='Ooops')
def access(): form = GithubUserForm() if form.validate_on_submit(): # GithubAPI object initialization github = apiwrap.GithubAPI(debug=app.config['DEBUG']) # redirect to github authorization login return redirect(github.get_github_auth_url()) return render_template('access.html', title='User', form=form)
def done(): username = '' repo = '' danger_str = '' if request.method == 'GET': if 'code' in request.args: code = request.args['code'] # GithubAPI object initialization github = apiwrap.GithubAPI(debug=app.config['DEBUG']) # Get user's token success_token = github.get_user_token(code) # check if the token was retrieved properly otherwise code might be invalid if success_token is False: danger_str = 'Code from Github is not valid, it expired or no access token obtained to start the process!\ Sorry! Please click Try Again!' flash(danger_str, 'danger') return render_template('fail.html', title='Ooops') # duplicates repo success_repo = github.duplicate_repo() # check if repo was successfully duplicated or not and display a message if success_repo: username = github.user.username repo = github.user.repo success_str = 'Successful Repo Duplication! Thanks!' flash(success_str, 'success') return render_template('thanks.html', title='Thanks', username=username, repo=repo) else: # Fail duplicating repo danger_str = 'Failure duplicating the repo! Sorry! Please Try Again!' else: # No code received danger_str = 'Ooops Github did not send a code to start the process or\ you got here the wrong way! Sorry! Please click Try Again!' else: # No GET request made danger_str = 'This page only processes GET requests with a valid code from Github for an OAuth app!' flash(danger_str, 'danger') return render_template('fail.html', title='Ooops')
def access(): form = GithubUserForm() if form.validate_on_submit(): #repo = 'https://github.com/{}/{}'.format(form.github_username.data, form.target_repo.data) #success_str = 'Repo {} has been created! Thanks {}!'.format(repo,form.github_username.data) #flash(success_str,'success') #flash(repo,'success') github = apiwrap.GithubAPI(debug=app.config['DEBUG']) #print( github.testAPI() ) return redirect(github.get_github_auth_url()) return render_template('access.html',title='User', form=form)
def docs(): github = apiwrap.GithubAPI(debug=app.config['DEBUG']) return redirect('https://github.com/{}/{}'.format(github.owner.username, github.owner.repo))