def index(): me = get_me() if me: repos = GitHubRepo.of(me.name) return fmt(list(map(lambda r: r.as_json, repos))) else: return fmt({'message': 'unavailable'}), 401
def repo_delete(owner, repo): me = get_me() repo = GitHubRepo.first_repo(owner, repo) if repo.owner == me.name: GitHubRepo.delete(repo.dn) # raises return '{"message": "OK"}' else: return '{"message": "unauthorized"}', 401
def create(): me = get_me() repo = request.form.get('repo') if repo: repo = repo.split('/') else: raise Exception("github `repo` variable required.") base_dn = GitHubRepo.create(*repo, base_dn=f'cn={me.cn}') if base_dn: return fmt({"message": "OK"})
def repo_claim(): """ create repo, under a username """ me = get_me() repo = request.form.get('repo') if repo: repo = repo.split('/') else: raise Exception("github `repo` variable required.") base_dn = GitHubRepo.create(*repo, base_dn=f'cn={me.cn}') response = make_response(redirect('/repos')) return response
def convert_endpt(): me = get_me() url = request.json.get('url') if not url: return 401, '{"message": "include url param"}' protocol, _, _domain, org, project, *rest = url.split('/') protocol = protocol.replace(':', '') rest = "/".join(rest) creds = get_creds(org, project) return dumps( {'url': convert(org, project, rest, creds.token, protocol=protocol)})
def welcome(): me = get_me() username = '' if me: username = me.cn with open(STATIC_DIR + '/index.html', 'r') as fp: template = Template(fp.read()) return template.substitute( host=HOST, domain=DOMAIN, paypalId=PAYPAL_CLIENT_ID, username=username )
def create(): me = get_me() content_client = GitContent(me) repo = request.form.get('repo') dry_run = request.form.get("dry_run") == "true" if repo: repo = repo.split('/') else: raise Exception("github `repo` variable required.") owner = content_client.owner(repo[0], repo[1]) if not owner: return fmt({"message": "not found"}), 404 if not dry_run: base_dn = GitHubRepo.create(*repo, base_dn=f'cn={me.cn}') if base_dn: return fmt({"message": "OK"}) else: return {"owner": owner}, 4
def before_request(): g.user = None if 'username' in session: # This is where you'd query your database to get the user info. g.user = get_me()
def before_request(): g.user = None if 'username' in session: g.user = get_me()
def new(): me = get_me() with open(STATIC_DIR + '/repo_new.html', 'r') as fp: template = Template(fp.read()) return template.substitute(username=me.name, host=HOST)