Merge branch 'orgs' of ssh://bitbucket.org/yackob03/quay into orgs

This commit is contained in:
yackob03 2013-11-01 14:44:22 -04:00
commit ecc4ad6e0f
5 changed files with 99 additions and 3 deletions

View file

@ -166,17 +166,53 @@ def verify_user(username, password):
# We weren't able to authorize the user
return None
class dotdict(dict):
def __getattr__(self, name):
return self[name]
def get_user_organizations(username):
# TODO: return the orgs that the user is apart of.
return [dotdict({
'username': 'testorg',
'email': 'testorg@quay.io'
})]
def lookup_organization(name, username=None):
if name == 'testorg':
return dotdict({
'username': 'testorg',
'email': 'testorg@quay.io'
})
return None
def get_user_teams(username, organization):
# TODO: return the teams that the user is apart of.
return [dotdict({
'id': 1234,
'name': 'Owners'
})]
def get_visible_repositories(username=None, include_public=True, limit=None,
sort=False):
sort=False, namespace=None):
if not username and not include_public:
return []
query = Repository.select().distinct().join(Visibility)
query = Repository.select().distinct()
if namespace:
query = query.where(Repository.namespace == namespace)
query = query.join(Visibility)
or_clauses = []
if include_public:
or_clauses.append((Visibility.name == 'public'))
if username:
with_perms = query.switch(Repository).join(RepositoryPermission,
JOIN_LEFT_OUTER)