diff --git a/templates/repo_recycle_view.html b/templates/repo_recycle_view.html
index db46580281..22409f02fa 100644
--- a/templates/repo_recycle_view.html
+++ b/templates/repo_recycle_view.html
@@ -42,12 +42,14 @@
{% if show_recycle_root %}
{{ dirent.obj_name }} |
{{ dirent.delete_time|translate_commit_time }} |
+ |
+ 还原 |
{% else %}
{{ dirent.obj_name }} |
|
+ |
+ |
{% endif %}
- |
- |
{% endfor %}
diff --git a/urls.py b/urls.py
index 83231a67ee..21a91b0507 100644
--- a/urls.py
+++ b/urls.py
@@ -49,6 +49,7 @@ urlpatterns = patterns('',
(r'^repo/file_rename/$', repo_rename_file),
(r'^repo/unsetinnerpub/(?P[^/]+)/$', unset_inner_pub_repo),
url(r'^repo/revert_file/(?P[^/]+)/$', repo_revert_file, name='repo_revert_file'),
+ url(r'^repo/revert_dir/(?P[^/]+)/$', repo_revert_dir, name='repo_revert_dir'),
url(r'^repo/upload_file/(?P[^/]+)/$', repo_upload_file, name='repo_upload_file'),
url(r'^repo/update_file/(?P[^/]+)/$', repo_update_file, name='repo_update_file'),
(r'^repo/upload_error/(?P[^/]+)/$', upload_file_error),
diff --git a/views.py b/views.py
index 5e7b87ec5b..5c72784218 100644
--- a/views.py
+++ b/views.py
@@ -2283,15 +2283,42 @@ def repo_revert_file (request, repo_id):
parent_dir = os.path.dirname(path)
url = reverse('repo', args=[repo_id]) + ('?p=%s' % urllib2.quote(parent_dir.encode('utf-8')))
- file_view_url = reverse('repo_view_file', args=[repo_id]) + u'?p=' + urllib2.quote(path.encode('utf-8'))
if ret == 1:
- msg = u'%s 已还原到根目录下' % (file_view_url, path.lstrip('/'))
+ root_url = reverse('repo', args=[repo_id]) + u'?p=/'
+ msg = u'%s 已还原到根目录下' % (path.lstrip('/'), root_url)
messages.add_message(request, messages.INFO, msg)
else:
+ file_view_url = reverse('repo_view_file', args=[repo_id]) + u'?p=' + urllib2.quote(path.encode('utf-8'))
msg = u'%s 已经还原' % (file_view_url, path.lstrip('/'))
messages.add_message(request, messages.INFO, msg)
return HttpResponseRedirect(url)
+@login_required
+def repo_revert_dir (request, repo_id):
+ commit_id = request.GET.get('commit')
+ path = request.GET.get('p')
+
+ if not (commit_id and path):
+ return render_error(request, u"参数错误")
+
+ try:
+ ret = seafserv_threaded_rpc.revert_dir (repo_id, commit_id,
+ path.encode('utf-8'), request.user.username)
+ except Exception, e:
+ return render_error(request, str(e))
+ else:
+ url = reverse('repo_recycle_view', args=[repo_id])
+
+ if ret == 1:
+ root_url = reverse('repo', args=[repo_id]) + u'?p=/'
+ msg = u'%s 已还原到根目录下' % (path.lstrip('/'), root_url)
+ messages.add_message(request, messages.INFO, msg)
+ else:
+ dir_view_url = reverse('repo', args=[repo_id]) + u'?p=' + urllib2.quote(path.encode('utf-8'))
+ msg = u'%s 已经还原' % (dir_view_url, path.lstrip('/'))
+ messages.add_message(request, messages.INFO, msg)
+ return HttpResponseRedirect(url)
+
@login_required
@ctx_switch_required
def file_revisions(request, repo_id):