1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-19 18:29:23 +00:00

[backbone] Improve listing sub-repos in API

This commit is contained in:
Daniel Pan
2015-03-30 23:11:13 +08:00
parent 1393bfe3f4
commit 8569ddc246

View File

@@ -560,20 +560,16 @@ class Repos(APIView):
# compose abbrev origin path for display # compose abbrev origin path for display
sub_repos = [] sub_repos = []
sub_lib_enabled = UserOptions.objects.is_sub_lib_enabled(email)
if settings.ENABLE_SUB_LIBRARY and sub_lib_enabled:
sub_repos = get_virtual_repos_by_owner(request) sub_repos = get_virtual_repos_by_owner(request)
for repo in sub_repos: for repo in sub_repos:
repo.abbrev_origin_path = get_abbrev_origin_path(repo.origin_repo_name, repo.abbrev_origin_path = get_abbrev_origin_path(
repo.origin_path) repo.origin_repo_name, repo.origin_path)
#calculate_repos_last_modify(sub_repos)
calculate_repo_info(sub_repos, email)
sub_repos.sort(lambda x, y: cmp(y.latest_modify, x.latest_modify)) sub_repos.sort(lambda x, y: cmp(y.latest_modify, x.latest_modify))
for r in sub_repos: for r in sub_repos:
print r._dict # print r._dict
repo = { repo = {
#"type":"repo", "type": "repo",
"encrypted":r.encrypted,
"id": r.id, "id": r.id,
"name": r.name, "name": r.name,
"origin_repo_id": r.origin_repo_id, "origin_repo_id": r.origin_repo_id,
@@ -581,18 +577,19 @@ class Repos(APIView):
"abbrev_origin_path": r.abbrev_origin_path, "abbrev_origin_path": r.abbrev_origin_path,
"mtime": r.latest_modify, "mtime": r.latest_modify,
"mtime_relative": translate_seahub_time(r.latest_modify), "mtime_relative": translate_seahub_time(r.latest_modify),
"is_original_owner": r.is_original_owner,
"owner": email, "owner": email,
"desc": r.desc, "desc": r.desc,
"root":r.root,
"size": r.size, "size": r.size,
"permission": 'rw', # TODO "encrypted": r.encrypted,
"permission": 'rw',
"virtual": r.is_virtual, "virtual": r.is_virtual,
} }
if r.encrypted:
repo["enc_version"] = r.enc_version
repo["magic"] = r.magic
repo["random_key"] = r.random_key
repos_json.append(repo) repos_json.append(repo)
if filter_by['shared']: if filter_by['shared']:
shared_repos = get_share_in_repo_list(request, -1, -1) shared_repos = get_share_in_repo_list(request, -1, -1)
for r in shared_repos: for r in shared_repos: