def delete_repo(id): repo = repos.get_repo_by_id(id) repo_acls = repos.get_repo_acls(repo_id=repo['repository_id'], user_id=request.user['user_id']) if not repo_acls or len(repo_acls) < 1 or not repo_acls[0]['is_owner']: raise Exception("Permission denied; user doesn't own this repository.") repos.delete_repo_by_id(id) return redirect(url_for('list_repos'))
def delete_repo(id): repo = repos.get_repo_by_id(id) repo_acls = repos.get_repo_acls( repo_id=repo['repository_id'], user_id=request.user['user_id']) if not repo_acls or len(repo_acls) < 1 or not repo_acls[0]['is_owner']: raise Exception("Permission denied; user doesn't own this repository.") repos.delete_repo_by_id(id) return redirect(url_for('list_repos'))
def assert_repo_permission(repo_id, permission): user_acls = repos.get_repo_acls(repo_id=repo_id, user_id=request.user['user_id']) user_acls = user_acls[0] if not user_acls[permission]: raise Exception("Permission denied; user {0} lacks {1} permissions" " for the repository with ID {2}".format( request.user['user_name'], permission, repo_id))
def assert_repo_permission(repo_id, permission): user_acls = repos.get_repo_acls( repo_id=repo_id, user_id=request.user['user_id']) user_acls = user_acls[0] if not user_acls[permission]: raise Exception("Permission denied; user {0} lacks {1} permissions" " for the repository with ID {2}".format( request.user['user_name'], permission, repo_id))
def render_repo_details(id, template): repo = repos.get_repo_by_id(id) repo_acls = repos.get_repo_acls(repo_id=repo['repository_id']) user_id = request.user['user_id'] user_acls = [a for a in repo_acls if a['user_id'] == user_id][0] # get our hostname for the git clone example import urlparse parsed_url = urlparse.urlparse(request.url) return render_template(template, repo=repo, repo_acls=repo_acls, hostname=parsed_url.hostname, user_acls=user_acls)