Start on controllers and the API for organizations. Also adds fake model methods
This commit is contained in:
parent
621f89f826
commit
d7148b1711
5 changed files with 99 additions and 3 deletions
|
@ -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)
|
||||
|
|
Reference in a new issue