1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-02 15:38:15 +00:00

Revert a deleted dir in recycle page.

This commit is contained in:
killing
2012-10-11 14:44:14 +08:00
parent 782d583e34
commit 2aecb8478c
3 changed files with 34 additions and 4 deletions

View File

@@ -42,12 +42,14 @@
{% if show_recycle_root %} {% if show_recycle_root %}
<td><a href="{% url 'repo_recycle_view' repo.id %}?commit_id={{ dirent.commit_id }}&base={{ dirent.basedir|urlencode }}&p=/{{ dirent.obj_name|urlencode }}">{{ dirent.obj_name }}</a></td> <td><a href="{% url 'repo_recycle_view' repo.id %}?commit_id={{ dirent.commit_id }}&base={{ dirent.basedir|urlencode }}&p=/{{ dirent.obj_name|urlencode }}">{{ dirent.obj_name }}</a></td>
<td>{{ dirent.delete_time|translate_commit_time }}</td> <td>{{ dirent.delete_time|translate_commit_time }}</td>
<td></td>
<td><a class="op" href="{% url 'repo_revert_dir' repo.id %}?commit={{ dirent.commit_id }}&p={{ dirent.basedir|urlencode }}{{dirent.obj_name|urlencode}}">还原</a></td>
{% else %} {% else %}
<td><a href="{% url 'repo_recycle_view' repo.id %}?commit_id={{ commit_id }}&base={{ basedir|urlencode }}&p={{ path|urlencode }}{{ dirent.obj_name|urlencode }}">{{ dirent.obj_name }}</a></td> <td><a href="{% url 'repo_recycle_view' repo.id %}?commit_id={{ commit_id }}&base={{ basedir|urlencode }}&p={{ path|urlencode }}{{ dirent.obj_name|urlencode }}">{{ dirent.obj_name }}</a></td>
<td></td> <td></td>
<td></td>
<td></td>
{% endif %} {% endif %}
<td></td>
<td></td>
</tr> </tr>
{% endfor %} {% endfor %}

View File

@@ -49,6 +49,7 @@ urlpatterns = patterns('',
(r'^repo/file_rename/$', repo_rename_file), (r'^repo/file_rename/$', repo_rename_file),
(r'^repo/unsetinnerpub/(?P<repo_id>[^/]+)/$', unset_inner_pub_repo), (r'^repo/unsetinnerpub/(?P<repo_id>[^/]+)/$', unset_inner_pub_repo),
url(r'^repo/revert_file/(?P<repo_id>[^/]+)/$', repo_revert_file, name='repo_revert_file'), url(r'^repo/revert_file/(?P<repo_id>[^/]+)/$', repo_revert_file, name='repo_revert_file'),
url(r'^repo/revert_dir/(?P<repo_id>[^/]+)/$', repo_revert_dir, name='repo_revert_dir'),
url(r'^repo/upload_file/(?P<repo_id>[^/]+)/$', repo_upload_file, name='repo_upload_file'), url(r'^repo/upload_file/(?P<repo_id>[^/]+)/$', repo_upload_file, name='repo_upload_file'),
url(r'^repo/update_file/(?P<repo_id>[^/]+)/$', repo_update_file, name='repo_update_file'), url(r'^repo/update_file/(?P<repo_id>[^/]+)/$', repo_update_file, name='repo_update_file'),
(r'^repo/upload_error/(?P<repo_id>[^/]+)/$', upload_file_error), (r'^repo/upload_error/(?P<repo_id>[^/]+)/$', upload_file_error),

View File

@@ -2283,15 +2283,42 @@ def repo_revert_file (request, repo_id):
parent_dir = os.path.dirname(path) parent_dir = os.path.dirname(path)
url = reverse('repo', args=[repo_id]) + ('?p=%s' % urllib2.quote(parent_dir.encode('utf-8'))) 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: if ret == 1:
msg = u'<a href="%s">%s</a> 已还原到根目录下' % (file_view_url, path.lstrip('/')) root_url = reverse('repo', args=[repo_id]) + u'?p=/'
msg = u'%s 已还原到<a href="%s">根目录</a>下' % (path.lstrip('/'), root_url)
messages.add_message(request, messages.INFO, msg) messages.add_message(request, messages.INFO, msg)
else: else:
file_view_url = reverse('repo_view_file', args=[repo_id]) + u'?p=' + urllib2.quote(path.encode('utf-8'))
msg = u'<a href="%s">%s</a> 已经还原' % (file_view_url, path.lstrip('/')) msg = u'<a href="%s">%s</a> 已经还原' % (file_view_url, path.lstrip('/'))
messages.add_message(request, messages.INFO, msg) messages.add_message(request, messages.INFO, msg)
return HttpResponseRedirect(url) 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 已还原到<a href="%s">根目录</a>下' % (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'<a href="%s">%s</a> 已经还原' % (dir_view_url, path.lstrip('/'))
messages.add_message(request, messages.INFO, msg)
return HttpResponseRedirect(url)
@login_required @login_required
@ctx_switch_required @ctx_switch_required
def file_revisions(request, repo_id): def file_revisions(request, repo_id):