Add ability to change the visibility of a repo, and show whether the repo is private in the repo-view screen
This commit is contained in:
parent
ce7620673b
commit
4382ebfd20
6 changed files with 214 additions and 11 deletions
|
@ -61,7 +61,7 @@ def match_repos_api(prefix):
|
|||
return {
|
||||
'namespace': repo.namespace,
|
||||
'name': repo.name,
|
||||
'description': repo.description,
|
||||
'description': repo.description
|
||||
}
|
||||
|
||||
username = current_user.db_user.username
|
||||
|
@ -111,6 +111,23 @@ def update_repo_api(namespace, repository):
|
|||
abort(404)
|
||||
|
||||
|
||||
@app.route('/api/repository/<path:repository>/changevisibility', methods=['POST'])
|
||||
@login_required
|
||||
@parse_repository_name
|
||||
def change_repo_visibility_api(namespace, repository):
|
||||
permission = AdministerRepositoryPermission(namespace, repository)
|
||||
if permission.can():
|
||||
repo = model.get_repository(namespace, repository)
|
||||
if repo:
|
||||
values = request.get_json()
|
||||
model.set_repository_visibility(repo, values['visibility'])
|
||||
return jsonify({
|
||||
'success': True
|
||||
})
|
||||
|
||||
abort(404)
|
||||
|
||||
|
||||
def image_view(image):
|
||||
return {
|
||||
'id': image.image_id,
|
||||
|
@ -136,7 +153,8 @@ def get_repo_api(namespace, repository):
|
|||
}
|
||||
|
||||
permission = ReadRepositoryPermission(namespace, repository)
|
||||
if permission.can() or model.repository_is_public(namespace, repository):
|
||||
is_public = model.repository_is_public(namespace, repository)
|
||||
if permission.can() or is_public:
|
||||
repo = model.get_repository(namespace, repository)
|
||||
if repo:
|
||||
tags = model.list_repository_tags(namespace, repository)
|
||||
|
@ -150,6 +168,7 @@ def get_repo_api(namespace, repository):
|
|||
'tags': tag_dict,
|
||||
'can_write': can_write,
|
||||
'can_admin': can_admin,
|
||||
'is_public': is_public
|
||||
})
|
||||
|
||||
abort(404) # Not fount
|
||||
|
|
Reference in a new issue