data.model._basequery: audited for repo_kind usage
This commit is contained in:
parent
f842bc3a82
commit
074c1bc4a8
1 changed files with 7 additions and 5 deletions
|
@ -10,7 +10,8 @@ def get_existing_repository(namespace_name, repository_name, for_update=False):
|
|||
query = (Repository
|
||||
.select(Repository, Namespace)
|
||||
.join(Namespace, on=(Repository.namespace_user == Namespace.id))
|
||||
.where(Namespace.username == namespace_name, Repository.name == repository_name))
|
||||
.where(Namespace.username == namespace_name,
|
||||
Repository.name == repository_name))
|
||||
if for_update:
|
||||
query = db_for_update(query)
|
||||
|
||||
|
@ -27,11 +28,14 @@ def _lookup_team_role(name):
|
|||
return TeamRole.get(name=name)
|
||||
|
||||
|
||||
def filter_to_repos_for_user(query, username=None, namespace=None, include_public=True,
|
||||
start_id=None):
|
||||
def filter_to_repos_for_user(query, username=None, namespace=None, repo_kind='image',
|
||||
include_public=True, start_id=None):
|
||||
if not include_public and not username:
|
||||
return Repository.select().where(Repository.id == '-1')
|
||||
|
||||
# Filter on the type of repository.
|
||||
query = query.where(Repository.kind == Repository.kind.get_id(repo_kind))
|
||||
|
||||
# Add the start ID if necessary.
|
||||
if start_id is not None:
|
||||
query = query.where(Repository.id >= start_id)
|
||||
|
@ -121,5 +125,3 @@ def calculate_image_aggregate_size(ancestors_str, image_size, parent_image):
|
|||
return None
|
||||
|
||||
return ancestor_size + image_size
|
||||
|
||||
|
||||
|
|
Reference in a new issue