Merge pull request #2515 from coreos-inc/app-redirect

Properly redirect to app repository URLs
This commit is contained in:
josephschorr 2017-04-05 14:34:37 -04:00 committed by GitHub
commit 6352b3cac5

View file

@ -703,11 +703,14 @@ def redirect_to_repository(namespace_name, repo_name, tag_name):
# Redirect to the repository page if the user can see the repository.
is_public = model.repository.repository_is_public(namespace_name, repo_name)
permission = ReadRepositoryPermission(namespace_name, repo_name)
repo_exists = bool(model.repository.get_repository(namespace_name, repo_name))
repo = model.repository.get_repository(namespace_name, repo_name)
if repo_exists and (permission.can() or is_public):
if repo and (permission.can() or is_public):
repo_path = '/'.join([namespace_name, repo_name])
return redirect(url_for('web.repository', path=repo_path, tab="tags", tag=tag_name))
if repo.kind.name == 'application':
return redirect(url_for('web.application', path=repo_path))
else:
return redirect(url_for('web.repository', path=repo_path, tab="tags", tag=tag_name))
namespace_exists = bool(model.user.get_user_or_org(namespace_name))
namespace_permission = OrganizationMemberPermission(namespace_name).can()