mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-17 22:47:59 +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>
|
<td>
|
||||||
{% if not commit.is_current_version %}
|
{% 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 %}
|
{% 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=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>
|
<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>
|
<li><a class="op file-update" href="{{ SITE_ROOT }}repo/update_file/{{repo.id}}/?p={{ path|urlencode }}{{dirent.obj_name|urlencode}}">更新</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if view_history and request.user.is_authenticated %}
|
{% 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 %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
8
views.py
8
views.py
@ -1801,8 +1801,9 @@ def render_file_revisions (request, repo_id):
|
|||||||
def repo_revert_file (request, repo_id):
|
def repo_revert_file (request, repo_id):
|
||||||
commit_id = request.GET.get('commit')
|
commit_id = request.GET.get('commit')
|
||||||
path = request.GET.get('p')
|
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"参数错误")
|
return render_error(request, u"参数错误")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -1811,6 +1812,11 @@ def repo_revert_file (request, repo_id):
|
|||||||
except Exception, e:
|
except Exception, e:
|
||||||
return render_error(request, str(e))
|
return render_error(request, str(e))
|
||||||
else:
|
else:
|
||||||
|
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)
|
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')))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user