service keys: join with approvals

Also fixes a bug where we weren't reassigning the query after adding a
WHERE.
This commit is contained in:
Jimmy Zelinskie 2016-03-30 16:51:32 -04:00 committed by Jimmy Zelinskie
parent 93720bd0f4
commit 86df0124c1

View file

@ -111,7 +111,7 @@ def approve_service_key(kid, approver, approval_type):
def _list_service_keys_query(kid=None, service=None, approved_only=False):
query = ServiceKey.select()
query = ServiceKey.select().join(ServiceKeyApproval)
if approved_only:
query = query.where(~(ServiceKey.approval >> None))
@ -122,7 +122,7 @@ def _list_service_keys_query(kid=None, service=None, approved_only=False):
~(_stale_unapproved_keys_clause(service)))
if kid is not None:
query.where(ServiceKey.kid == kid)
query = query.where(ServiceKey.kid == kid)
return query