mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-30 04:25:47 +00:00
Rename several apis
This commit is contained in:
parent
b15ebbe426
commit
62bf4b11ce
@ -5,11 +5,11 @@
|
|||||||
{% block left_panel %}
|
{% block left_panel %}
|
||||||
<ul>
|
<ul>
|
||||||
{% if is_owner %}
|
{% if is_owner %}
|
||||||
{% if repo_role and repo_role != 'private' %}
|
{% if repo_ap and repo_ap != 'private' %}
|
||||||
<li><a href="{{ SITE_ROOT }}repo/dir/{{ repo.props.id }}/">浏览</a></li>
|
<li><a href="{{ SITE_ROOT }}repo/dir/{{ repo.props.id }}/">浏览</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if repo_role == 'public' %}
|
{% if repo_ap == 'public' %}
|
||||||
<li><a href="{{ SITE_ROOT }}repo/dir/{{ repo.props.id }}/">浏览</a></li>
|
<li><a href="{{ SITE_ROOT }}repo/dir/{{ repo.props.id }}/">浏览</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -55,19 +55,19 @@
|
|||||||
<th>公共访问</th>
|
<th>公共访问</th>
|
||||||
{% if is_owner %}
|
{% if is_owner %}
|
||||||
<td>
|
<td>
|
||||||
{% if repo_role == 'public' %}
|
{% if repo_ap == 'public' %}
|
||||||
<input type="radio" id="repo-role" name="repo-role" value="public" checked>开启
|
<input type="radio" id="repo-role" name="repo-role" value="public" checked>开启
|
||||||
{% else %}
|
{% else %}
|
||||||
<input type="radio" id="repo-role" name="repo-role" value="public">开启
|
<input type="radio" id="repo-role" name="repo-role" value="public">开启
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if repo_role == 'own' %}
|
{% if repo_ap == 'own' %}
|
||||||
<input type="radio" id="repo-role" name="repo-role" value="own" checked>只对自己开启
|
<input type="radio" id="repo-role" name="repo-role" value="own" checked>只对自己开启
|
||||||
{% else %}
|
{% else %}
|
||||||
<input type="radio" id="repo-role" name="repo-role" value="own">只对自己开启
|
<input type="radio" id="repo-role" name="repo-role" value="own">只对自己开启
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if not repo_role or repo_role == 'private'%}
|
{% if not repo_ap or repo_ap == 'private'%}
|
||||||
<input type="radio" id="repo-role" name="repo-role" value="private" checked>关闭
|
<input type="radio" id="repo-role" name="repo-role" value="private" checked>关闭
|
||||||
{% else %}
|
{% else %}
|
||||||
<input type="radio" id="repo-role" name="repo-role" value="private">关闭
|
<input type="radio" id="repo-role" name="repo-role" value="private">关闭
|
||||||
@ -144,7 +144,7 @@ $(function(){
|
|||||||
$("input[name='repo-role']").click(
|
$("input[name='repo-role']").click(
|
||||||
function(){
|
function(){
|
||||||
var item = $("input[name='repo-role']:checked").val();
|
var item = $("input[name='repo-role']:checked").val();
|
||||||
location.href = "{{ SITE_ROOT }}repo/setrole/{{ repo.props.id}}/"+item+"/";
|
location.href = "{{ SITE_ROOT }}repo/setap/{{ repo.props.id}}/"+item+"/";
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
4
urls.py
4
urls.py
@ -6,7 +6,7 @@ from seahub.views import root, peers, groups, myhome, \
|
|||||||
repo, group, modify_token, remove_repo, seafadmin, useradmin, \
|
repo, group, modify_token, remove_repo, seafadmin, useradmin, \
|
||||||
role_add, role_remove, activate_user, user_add, user_remove, \
|
role_add, role_remove, activate_user, user_add, user_remove, \
|
||||||
ownerhome, remove_fetched_repo, repo_set_public, repo_unset_public, \
|
ownerhome, remove_fetched_repo, repo_set_public, repo_unset_public, \
|
||||||
repo_list_dir, user_info, repo_set_role, repo_operation_file
|
repo_list_dir, user_info, repo_set_access_property, repo_operation_file
|
||||||
|
|
||||||
# Uncomment the next two lines to enable the admin:
|
# Uncomment the next two lines to enable the admin:
|
||||||
#from django.contrib import admin
|
#from django.contrib import admin
|
||||||
@ -35,7 +35,7 @@ urlpatterns = patterns('',
|
|||||||
(r'^repo/removefetched/(?P<user_id>[^/]+)/(?P<repo_id>[^/]+)/$', remove_fetched_repo),
|
(r'^repo/removefetched/(?P<user_id>[^/]+)/(?P<repo_id>[^/]+)/$', remove_fetched_repo),
|
||||||
(r'^repo/setpublic/(?P<repo_id>[^/]+)/$', repo_set_public),
|
(r'^repo/setpublic/(?P<repo_id>[^/]+)/$', repo_set_public),
|
||||||
(r'^repo/unsetpublic/(?P<repo_id>[^/]+)/$', repo_unset_public),
|
(r'^repo/unsetpublic/(?P<repo_id>[^/]+)/$', repo_unset_public),
|
||||||
(r'^repo/setrole/(?P<repo_id>[^/]+)/(?P<role_name>[^/]+)/$', repo_set_role),
|
(r'^repo/setap/(?P<repo_id>[^/]+)/(?P<ap>[^/]+)/$', repo_set_access_property),
|
||||||
(r'^repo/dir/(?P<repo_id>[^/]+)/$', repo_list_dir),
|
(r'^repo/dir/(?P<repo_id>[^/]+)/$', repo_list_dir),
|
||||||
(r'^repo/(?P<op>[^/]+)/(?P<repo_id>[^/]+)/(?P<obj_id>[^/]+)/(?P<file_name>[^/]+)/$', repo_operation_file),
|
(r'^repo/(?P<op>[^/]+)/(?P<repo_id>[^/]+)/(?P<obj_id>[^/]+)/(?P<file_name>[^/]+)/$', repo_operation_file),
|
||||||
|
|
||||||
|
36
views.py
36
views.py
@ -142,13 +142,13 @@ def repo(request, repo_id):
|
|||||||
|
|
||||||
token = ""
|
token = ""
|
||||||
is_owner = False
|
is_owner = False
|
||||||
repo_role = ""
|
repo_ap = ""
|
||||||
|
|
||||||
if request.user.is_authenticated():
|
if request.user.is_authenticated():
|
||||||
if validate_owner(request, repo_id):
|
if validate_owner(request, repo_id):
|
||||||
is_owner = True
|
is_owner = True
|
||||||
token = seafserv_threaded_rpc.get_repo_token(repo_id)
|
token = seafserv_threaded_rpc.get_repo_token(repo_id)
|
||||||
repo_role = seafserv_threaded_rpc.repo_query_role(repo_id)
|
repo_ap = seafserv_threaded_rpc.repo_query_access_property(repo_id)
|
||||||
|
|
||||||
return render_to_response('repo.html', {
|
return render_to_response('repo.html', {
|
||||||
"repo": repo,
|
"repo": repo,
|
||||||
@ -160,7 +160,7 @@ def repo(request, repo_id):
|
|||||||
'page_next': page_next,
|
'page_next': page_next,
|
||||||
"branches": branches,
|
"branches": branches,
|
||||||
"is_owner": is_owner,
|
"is_owner": is_owner,
|
||||||
"repo_role": repo_role,
|
"repo_ap": repo_ap,
|
||||||
"token": token,
|
"token": token,
|
||||||
}, context_instance=RequestContext(request))
|
}, context_instance=RequestContext(request))
|
||||||
|
|
||||||
@ -217,21 +217,11 @@ def myhome(request):
|
|||||||
frepos = seafserv_threaded_rpc.list_fetched_repos(user_id)
|
frepos = seafserv_threaded_rpc.list_fetched_repos(user_id)
|
||||||
for repo in frepos:
|
for repo in frepos:
|
||||||
repo.userid = user_id # associate a fetched repo with the user id
|
repo.userid = user_id # associate a fetched repo with the user id
|
||||||
# if seafserv_threaded_rpc.repo_is_public(repo.props.id):
|
|
||||||
# repo.is_public = True
|
|
||||||
# else:
|
|
||||||
# repo.is_public = False
|
|
||||||
|
|
||||||
fetched_repos.extend(frepos)
|
fetched_repos.extend(frepos)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# for repo in owned_repos:
|
|
||||||
# if seafserv_threaded_rpc.repo_query_role(repo.props.id) == 'public':
|
|
||||||
# repo.is_public = True
|
|
||||||
# else:
|
|
||||||
# repo.is_public = False
|
|
||||||
|
|
||||||
return render_to_response('myhome.html', {
|
return render_to_response('myhome.html', {
|
||||||
"owned_repos": owned_repos,
|
"owned_repos": owned_repos,
|
||||||
"quota_usage": quota_usage,
|
"quota_usage": quota_usage,
|
||||||
@ -276,9 +266,9 @@ def repo_unset_public(request, repo_id):
|
|||||||
return HttpResponseRedirect(request.META['HTTP_REFERER'])
|
return HttpResponseRedirect(request.META['HTTP_REFERER'])
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def repo_set_role(request, repo_id, role_name):
|
def repo_set_access_property(request, repo_id, ap):
|
||||||
if repo_id and role_name:
|
if repo_id and ap:
|
||||||
seafserv_threaded_rpc.repo_set_role(repo_id, role_name)
|
seafserv_threaded_rpc.repo_set_access_property(repo_id, ap)
|
||||||
|
|
||||||
return HttpResponseRedirect(request.META['HTTP_REFERER'])
|
return HttpResponseRedirect(request.META['HTTP_REFERER'])
|
||||||
|
|
||||||
@ -286,13 +276,13 @@ def repo_set_role(request, repo_id, role_name):
|
|||||||
def repo_list_dir(request, repo_id):
|
def repo_list_dir(request, repo_id):
|
||||||
if repo_id:
|
if repo_id:
|
||||||
# any person visit private repo, go to 404 page
|
# any person visit private repo, go to 404 page
|
||||||
repo_role = seafserv_threaded_rpc.repo_query_role(repo_id)
|
repo_ap = seafserv_threaded_rpc.repo_query_access_property(repo_id)
|
||||||
if repo_role == 'private':
|
if repo_ap == 'private':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
# people who is not owner visits own repo, go to 404 page
|
# people who is not owner visits own repo, go to 404 page
|
||||||
if not validate_owner(request, repo_id):
|
if not validate_owner(request, repo_id):
|
||||||
if repo_role == 'own':
|
if repo_ap == 'own':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
repo = seafserv_threaded_rpc.get_repo(repo_id)
|
repo = seafserv_threaded_rpc.get_repo(repo_id)
|
||||||
@ -319,12 +309,12 @@ def repo_list_dir(request, repo_id):
|
|||||||
def repo_operation_file(request, op, repo_id, obj_id, file_name):
|
def repo_operation_file(request, op, repo_id, obj_id, file_name):
|
||||||
if repo_id:
|
if repo_id:
|
||||||
# any person visit private repo, go to 404 page
|
# any person visit private repo, go to 404 page
|
||||||
repo_role = seafserv_threaded_rpc.repo_query_role(repo_id)
|
repo_ap = seafserv_threaded_rpc.repo_query_access_property(repo_id)
|
||||||
if repo_role == 'private':
|
if repo_ap == 'private':
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
token = ''
|
token = ''
|
||||||
if repo_role == 'own':
|
if repo_ap == 'own':
|
||||||
# people who is not owner visits own repo, go to 404 page
|
# people who is not owner visits own repo, go to 404 page
|
||||||
if not validate_owner(request, repo_id):
|
if not validate_owner(request, repo_id):
|
||||||
raise Http404
|
raise Http404
|
||||||
@ -332,7 +322,7 @@ def repo_operation_file(request, op, repo_id, obj_id, file_name):
|
|||||||
# owner should get a token to visit repo
|
# owner should get a token to visit repo
|
||||||
token = gen_token()
|
token = gen_token()
|
||||||
# put token into memory in seaf-server
|
# put token into memory in seaf-server
|
||||||
seafserv_threaded_rpc.repo_save_access_token(token, obj_id)
|
seafserv_rpc.web_save_access_token(token, obj_id)
|
||||||
|
|
||||||
http_server_root = get_httpserver_root()
|
http_server_root = get_httpserver_root()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user