mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-18 16:36:15 +00:00
[backbone] Improve listing sub-repos in API
This commit is contained in:
@@ -556,42 +556,39 @@ class Repos(APIView):
|
|||||||
abbrev_path = path[-20:]
|
abbrev_path = path[-20:]
|
||||||
return repo_name + '/...' + abbrev_path
|
return repo_name + '/...' + abbrev_path
|
||||||
else:
|
else:
|
||||||
return repo_name + path
|
return repo_name + path
|
||||||
|
|
||||||
# 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)
|
sub_repos = get_virtual_repos_by_owner(request)
|
||||||
if settings.ENABLE_SUB_LIBRARY and sub_lib_enabled:
|
for repo in sub_repos:
|
||||||
sub_repos = get_virtual_repos_by_owner(request)
|
repo.abbrev_origin_path = get_abbrev_origin_path(
|
||||||
for repo in sub_repos:
|
repo.origin_repo_name, repo.origin_path)
|
||||||
repo.abbrev_origin_path = get_abbrev_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))
|
|
||||||
for r in sub_repos:
|
|
||||||
print r._dict
|
|
||||||
repo = {
|
|
||||||
#"type":"repo",
|
|
||||||
"encrypted":r.encrypted,
|
|
||||||
"id":r.id,
|
|
||||||
"name":r.name,
|
|
||||||
"origin_repo_id": r.origin_repo_id,
|
|
||||||
"origin_path": r.origin_path,
|
|
||||||
"abbrev_origin_path": r.abbrev_origin_path,
|
|
||||||
"mtime": r.latest_modify,
|
|
||||||
"mtime_relative": translate_seahub_time(r.latest_modify),
|
|
||||||
"is_original_owner": r.is_original_owner,
|
|
||||||
|
|
||||||
"owner":email,
|
|
||||||
"desc":r.desc,
|
|
||||||
"root":r.root,
|
|
||||||
"size":r.size,
|
|
||||||
"permission": 'rw', # TODO
|
|
||||||
"virtual": r.is_virtual,
|
|
||||||
}
|
|
||||||
repos_json.append(repo)
|
|
||||||
|
|
||||||
|
sub_repos.sort(lambda x, y: cmp(y.latest_modify, x.latest_modify))
|
||||||
|
for r in sub_repos:
|
||||||
|
# print r._dict
|
||||||
|
repo = {
|
||||||
|
"type": "repo",
|
||||||
|
"id": r.id,
|
||||||
|
"name": r.name,
|
||||||
|
"origin_repo_id": r.origin_repo_id,
|
||||||
|
"origin_path": r.origin_path,
|
||||||
|
"abbrev_origin_path": r.abbrev_origin_path,
|
||||||
|
"mtime": r.latest_modify,
|
||||||
|
"mtime_relative": translate_seahub_time(r.latest_modify),
|
||||||
|
"owner": email,
|
||||||
|
"desc": r.desc,
|
||||||
|
"size": r.size,
|
||||||
|
"encrypted": r.encrypted,
|
||||||
|
"permission": 'rw',
|
||||||
|
"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)
|
||||||
|
|
||||||
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)
|
||||||
|
Reference in New Issue
Block a user