1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-25 14:50:29 +00:00

[api2] Add magic and random_key to repo

This commit is contained in:
poetwang
2013-10-18 01:01:43 +08:00
parent cd762fe60a
commit 7cc9725665
2 changed files with 17 additions and 6 deletions

View File

@@ -39,7 +39,7 @@ urlpatterns = patterns('',
# Folowing is only for debug, will be removed # Folowing is only for debug, will be removed
#url(r'^html/newreply2/$', api_new_replies), #url(r'^html/newreply2/$', api_new_replies),
#url(r'^html/events2/$', activity2), #url(r'^html/events2/$', activity2),
#url(r'^html/more_events/$', events2), #url(r'^html/more_events/$', events2, name="more_events"),
#url(r'^html/repo_history_changes/(?P<repo_id>[-0-9a-f]{36})/$', api_repo_history_changes, name='api_repo_history_changes'), #url(r'^html/repo_history_changes/(?P<repo_id>[-0-9a-f]{36})/$', api_repo_history_changes, name='api_repo_history_changes'),
#url(r'^html/discussions2/(?P<group_id>\d+)/$', discussions2, name="api_discussions2"), #url(r'^html/discussions2/(?P<group_id>\d+)/$', discussions2, name="api_discussions2"),

View File

@@ -306,9 +306,12 @@ class Repos(APIView):
"root":r.root, "root":r.root,
"size":r.size, "size":r.size,
"encrypted":r.encrypted, "encrypted":r.encrypted,
"enc_version":r.enc_version,
"permission": 'rw', # Always have read-write permission to owned repo "permission": 'rw', # Always have read-write permission to owned repo
} }
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)
shared_repos = seafile_api.get_share_in_repo_list(email, -1, -1) shared_repos = seafile_api.get_share_in_repo_list(email, -1, -1)
@@ -331,9 +334,12 @@ class Repos(APIView):
"root":r.root, "root":r.root,
"size":r.size, "size":r.size,
"encrypted":r.encrypted, "encrypted":r.encrypted,
"enc_version":r.enc_version,
"permission": r.permission, "permission": r.permission,
} }
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)
groups = get_personal_groups_by_user(email) groups = get_personal_groups_by_user(email)
@@ -353,11 +359,13 @@ class Repos(APIView):
"root":r.root, "root":r.root,
"size":r.size, "size":r.size,
"encrypted":r.encrypted, "encrypted":r.encrypted,
"enc_version":r.enc_version,
"permission": check_permission(r.id, email), "permission": check_permission(r.id, email),
} }
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)
return Response(repos_json) return Response(repos_json)
def post(self, request, format=None): def post(self, request, format=None):
@@ -478,10 +486,13 @@ class Repo(APIView):
"mtime":repo.latest_modify, "mtime":repo.latest_modify,
"size":repo.size, "size":repo.size,
"encrypted":repo.encrypted, "encrypted":repo.encrypted,
"enc_version":repo.encversion,
"root":root_id, "root":root_id,
"permission": check_permission(repo.id, username), "permission": check_permission(repo.id, username),
} }
if repo.encrypted:
repo_json["enc_version"] = repo.enc_version
repo_json["magic"] = repo.magic
repo_json["random_key"] = repo.random_key
return Response(repo_json) return Response(repo_json)