mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-01 23:38:37 +00:00
redirect to repo history when revert file from repo histoy view
This commit is contained in:
parent
3470b73939
commit
5bf1743882
@ -42,7 +42,7 @@
|
||||
|
||||
<td>
|
||||
{% if not commit.is_current_version %}
|
||||
<a href="{{ SITE_ROOT }}repo/revert_file/{{ repo.id }}/?commit={{ commit.id }}&p={{path|urlencode}}" class="file-revert op">还原</a>
|
||||
<a href="{{ SITE_ROOT }}repo/revert_file/{{ repo.id }}/?commit={{ commit.id }}&p={{path|urlencode}}&from=file_revisions" class="file-revert op">还原</a>
|
||||
{% endif %}
|
||||
<a href="{{ SITE_ROOT }}repo/file_revisions/{{ repo.id }}/?commit={{ commit.id }}&p={{path|urlencode}}&op=download" class="file-download op">下载</a>
|
||||
<a href="{{ SITE_ROOT }}repo/file_revisions/{{ repo.id }}/?commit={{ commit.id }}&p={{path|urlencode}}&op=view" class="file-download op">查看</a>
|
||||
|
@ -184,7 +184,7 @@
|
||||
<li><a class="op file-update" href="{{ SITE_ROOT }}repo/update_file/{{repo.id}}/?p={{ path|urlencode }}{{dirent.obj_name|urlencode}}">更新</a></li>
|
||||
{% endif %}
|
||||
{% if view_history and request.user.is_authenticated %}
|
||||
<li><a href="{{ SITE_ROOT }}repo/revert_file/{{ repo.id }}/?commit={{ current_commit.id }}&p={{path|urlencode}}{{ dirent.obj_name|urlencode }}" class="op file-revert">还原</a></li>
|
||||
<li><a href="{{ SITE_ROOT }}repo/revert_file/{{ repo.id }}/?commit={{ current_commit.id }}&p={{path|urlencode}}{{ dirent.obj_name|urlencode }}&from=repo_history" class="op file-revert">还原</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
|
12
views.py
12
views.py
@ -1801,8 +1801,9 @@ def render_file_revisions (request, repo_id):
|
||||
def repo_revert_file (request, repo_id):
|
||||
commit_id = request.GET.get('commit')
|
||||
path = request.GET.get('p')
|
||||
from_page = request.GET.get('from')
|
||||
|
||||
if not (commit_id and path):
|
||||
if not (commit_id and path and from_page):
|
||||
return render_error(request, u"参数错误")
|
||||
|
||||
try:
|
||||
@ -1811,8 +1812,13 @@ def repo_revert_file (request, repo_id):
|
||||
except Exception, e:
|
||||
return render_error(request, str(e))
|
||||
else:
|
||||
parent_dir = os.path.dirname(path)
|
||||
url = reverse('repo', args=[repo_id]) + ('?p=%s' % urllib2.quote(parent_dir.encode('utf-8')))
|
||||
if from_page == 'repo_history':
|
||||
# When revert file from repo history, we redirect to repo history
|
||||
url = reverse('repo', args=[repo_id]) + u'?commit_id=%s&history=y' % commit_id
|
||||
else:
|
||||
# When revert file from file history, we redirect to parent dir of this file
|
||||
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:
|
||||
|
Loading…
Reference in New Issue
Block a user