mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-25 14:50:29 +00:00
Merge branch 'revert'
This commit is contained in:
@@ -27,7 +27,10 @@
|
||||
{% endif %}
|
||||
<td>{{ commit.props.desc|translate_commit_desc }}</td>
|
||||
{% if not forloop.last %}
|
||||
<td><a href="{{ SITE_ROOT }}repo/history/dir/{{ repo.id }}/?commit_id={{ commit.id }}">浏览</a></td>
|
||||
<td>
|
||||
<a href="{{ SITE_ROOT }}repo/history/dir/{{ repo.id }}/?commit_id={{ commit.id }}">浏览</a>
|
||||
<a href="{{ SITE_ROOT }}repo/history/revert/{{ repo.id }}/?commit_id={{ commit.id }}">还原</a>
|
||||
</td>
|
||||
{% else %}
|
||||
<td></td>
|
||||
{% endif %}
|
||||
|
3
urls.py
3
urls.py
@@ -5,7 +5,7 @@ from django.views.generic.simple import direct_to_template
|
||||
from seahub.views import root, peers, myhome, \
|
||||
repo, repo_history, modify_token, remove_repo, seafadmin, useradmin, \
|
||||
role_add, role_remove, activate_user, user_add, user_remove, \
|
||||
ownerhome, remove_fetched_repo, repo_history_dir, \
|
||||
ownerhome, remove_fetched_repo, repo_history_dir, repo_history_revert, \
|
||||
user_info, repo_set_access_property, repo_access_file, \
|
||||
repo_add_share, repo_list_share, repo_remove_share, repo_download, \
|
||||
seafile_access_check, back_local
|
||||
@@ -39,6 +39,7 @@ urlpatterns = patterns('',
|
||||
(r'^repo/(?P<repo_id>[^/]+)/$', repo),
|
||||
(r'^repo/history/(?P<repo_id>[^/]+)/$', repo_history),
|
||||
(r'^repo/history/dir/(?P<repo_id>[^/]+)/$', repo_history_dir),
|
||||
(r'^repo/history/revert/(?P<repo_id>[^/]+)/$', repo_history_revert),
|
||||
(r'^repo/token/modify/(?P<repo_id>[^/]+)/$', modify_token),
|
||||
(r'^repo/remove/(?P<repo_id>[^/]+)/$', remove_repo),
|
||||
(r'^repo/removefetched/(?P<user_id>[^/]+)/(?P<repo_id>[^/]+)/$', remove_fetched_repo),
|
||||
|
45
views.py
45
views.py
@@ -366,6 +366,51 @@ def repo_history_dir(request, repo_id):
|
||||
"zipped" : zipped,
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
def repo_history_revert(request, repo_id):
|
||||
repo_ap = seafserv_threaded_rpc.repo_query_access_property(repo_id)
|
||||
if repo_ap == None:
|
||||
repo_ap = 'own'
|
||||
|
||||
if not access_to_repo(request, repo_id, repo_ap):
|
||||
raise Http404
|
||||
|
||||
repo = get_repo(repo_id)
|
||||
if not repo:
|
||||
raise Http404
|
||||
|
||||
password_set = False
|
||||
if repo.props.encrypted:
|
||||
try:
|
||||
ret = seafserv_rpc.is_passwd_set(repo_id, request.user.username)
|
||||
if ret == 1:
|
||||
password_set = True
|
||||
except SearpcError, e:
|
||||
return go_error(request, e.msg)
|
||||
|
||||
if repo.props.encrypted and not password_set:
|
||||
return HttpResponseRedirect('/repo/%s/' % repo_id)
|
||||
|
||||
commit_id = request.GET.get('commit_id', '')
|
||||
if not commit_id:
|
||||
return go_error(request, u'请指定历史记录 ID')
|
||||
|
||||
res = request.user.username.split('@')
|
||||
user_name = res[0]
|
||||
|
||||
try:
|
||||
seafserv_threaded_rpc.revert_on_server(repo_id, commit_id, user_name)
|
||||
except SearpcError, e:
|
||||
if e.msg == 'Bad arguments':
|
||||
return go_error(request, u'非法参数')
|
||||
elif e.msg == 'No such repo':
|
||||
return go_error(request, u'同步目录不存在')
|
||||
elif e.msg == "Commit doesn't exist":
|
||||
return go_error(request, u'指定的历史记录不存在')
|
||||
else:
|
||||
return go_error(request, u'未知错误')
|
||||
|
||||
return HttpResponseRedirect(reverse(repo_history, args=[repo_id]))
|
||||
|
||||
@login_required
|
||||
def modify_token(request, repo_id):
|
||||
if not validate_owner(request, repo_id):
|
||||
|
Reference in New Issue
Block a user