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

rm "urllib2.quote" when reverse url

This commit is contained in:
lian
2016-04-19 15:44:23 +08:00
parent 8bb44749eb
commit fcd51a67df

View File

@@ -743,11 +743,11 @@ def repo_revert_history(request, repo_id):
def fpath_to_link(repo_id, path, is_dir=False): def fpath_to_link(repo_id, path, is_dir=False):
"""Translate file path of a repo to its view link""" """Translate file path of a repo to its view link"""
if is_dir: if is_dir:
href = reverse("view_common_lib_dir", args=[repo_id, urllib2.quote(path.encode('utf-8')).strip('/')]) href = reverse("view_common_lib_dir", args=[repo_id, path.encode('utf-8').strip('/')])
else: else:
if not path.startswith('/'): if not path.startswith('/'):
p = '/' + path p = '/' + path
href = reverse("view_lib_file", args=[repo_id, urllib2.quote(p.encode('utf-8'))]) href = reverse("view_lib_file", args=[repo_id, p.encode('utf-8')])
return '<a href="%s">%s</a>' % (href, escape(path)) return '<a href="%s">%s</a>' % (href, escape(path))
@@ -1113,7 +1113,7 @@ def repo_revert_file(request, repo_id):
msg = _(u'Successfully revert %(path)s to <a href="%(root)s">root directory.</a>') % {"path": escape(path.lstrip('/')), "root": root_url} msg = _(u'Successfully revert %(path)s to <a href="%(root)s">root directory.</a>') % {"path": escape(path.lstrip('/')), "root": root_url}
messages.success(request, msg, extra_tags='safe') messages.success(request, msg, extra_tags='safe')
else: else:
file_view_url = reverse('view_lib_file', args=[repo_id, urllib2.quote(path.encode('utf-8'))]) file_view_url = reverse('view_lib_file', args=[repo_id, path.encode('utf-8')])
msg = _(u'Successfully revert <a href="%(url)s">%(path)s</a>') % {"url": file_view_url, "path": escape(path.lstrip('/'))} msg = _(u'Successfully revert <a href="%(url)s">%(path)s</a>') % {"url": file_view_url, "path": escape(path.lstrip('/'))}
messages.success(request, msg, extra_tags='safe') messages.success(request, msg, extra_tags='safe')
@@ -1152,7 +1152,7 @@ def repo_revert_dir(request, repo_id):
msg = _(u'Successfully revert %(path)s to <a href="%(url)s">root directory.</a>') % {"path": escape(path.lstrip('/')), "url": root_url} msg = _(u'Successfully revert %(path)s to <a href="%(url)s">root directory.</a>') % {"path": escape(path.lstrip('/')), "url": root_url}
messages.success(request, msg, extra_tags='safe') messages.success(request, msg, extra_tags='safe')
else: else:
dir_view_url = reverse('view_common_lib_dir', args=[repo_id, urllib2.quote(path.strip('/').encode('utf-8'))]) dir_view_url = reverse('view_common_lib_dir', args=[repo_id, path.strip('/').encode('utf-8')])
msg = _(u'Successfully revert <a href="%(url)s">%(path)s</a>') % {"url": dir_view_url, "path": escape(path.lstrip('/'))} msg = _(u'Successfully revert <a href="%(url)s">%(path)s</a>') % {"url": dir_view_url, "path": escape(path.lstrip('/'))}
messages.success(request, msg, extra_tags='safe') messages.success(request, msg, extra_tags='safe')