mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-19 10:26:17 +00:00
Redirect to wiki page when edit page, and fixed a few bugs
This commit is contained in:
@@ -191,7 +191,7 @@ def get_repo_dirents(request, repo_id, commit, path):
|
||||
return ([], [])
|
||||
else:
|
||||
try:
|
||||
dirs = seafile_api.list_dir_by_commit_and_path(commit.id, path.encode('utf-8'))
|
||||
dirs = seafile_api.list_dir_by_commit_and_path(commit.id, path)
|
||||
except SearpcError, e:
|
||||
raise Http404
|
||||
# return render_error(self.request, e.msg)
|
||||
@@ -1487,8 +1487,8 @@ def file_revisions(request, repo_id):
|
||||
def handle_download():
|
||||
parent_dir = os.path.dirname(path)
|
||||
file_name = os.path.basename(path)
|
||||
seafdir = seafile_api.list_dir_by_commit_and_path (commit_id, \
|
||||
parent_dir.encode('utf-8'))
|
||||
seafdir = seafile_api.list_dir_by_commit_and_path (commit_id,
|
||||
parent_dir)
|
||||
if not seafdir:
|
||||
return render_error(request)
|
||||
|
||||
|
@@ -736,14 +736,15 @@ def file_edit_submit(request, repo_id):
|
||||
status=400,
|
||||
content_type=content_type)
|
||||
|
||||
if get_user_permission(request, repo_id) != 'rw':
|
||||
username = request.user.username
|
||||
if get_repo_access_permission(repo_id, username) != 'rw':
|
||||
return error_json(_(u'Permission denied'))
|
||||
|
||||
repo = get_repo(repo_id)
|
||||
if not repo:
|
||||
return error_json(_(u'The library does not exist.'))
|
||||
if repo.encrypted:
|
||||
repo.password_set = seafile_api.is_passwd_set(repo_id, request.user.username)
|
||||
repo.password_set = seafile_api.is_passwd_set(repo_id, username)
|
||||
if not repo.password_set:
|
||||
return error_json(_(u'The library is encrypted.'), 'decrypt')
|
||||
|
||||
@@ -776,24 +777,18 @@ def file_edit_submit(request, repo_id):
|
||||
remove_tmp_file()
|
||||
return error_json()
|
||||
|
||||
if request.GET.get('from', '') == 'wiki_page_edit':
|
||||
req_from = request.GET.get('from', '')
|
||||
if req_from == 'wiki_page_edit' or req_from == 'wiki_page_new':
|
||||
try:
|
||||
gid = int(request.GET.get('gid', 0))
|
||||
except ValueError:
|
||||
gid = 0
|
||||
|
||||
wiki_name = os.path.splitext(os.path.basename(path))[0]
|
||||
next = reverse('group_wiki', args=[gid, wiki_name])
|
||||
elif request.GET.get('from', '') == 'wiki_page_new':
|
||||
try:
|
||||
gid = int(request.GET.get('gid', 0))
|
||||
except ValueError:
|
||||
gid = 0
|
||||
next = reverse('group_wiki_pages', args=[gid])
|
||||
elif request.GET.get('from', '') == 'personal_wiki_page_edit':
|
||||
elif req_from == 'personal_wiki_page_edit' or req_from == 'personal_wiki_page_new':
|
||||
wiki_name = os.path.splitext(os.path.basename(path))[0]
|
||||
next = reverse('personal_wiki', args=[wiki_name])
|
||||
elif request.GET.get('from', '') == 'personal_wiki_page_new':
|
||||
next = reverse('personal_wiki_pages')
|
||||
else:
|
||||
next = reverse('repo_view_file', args=[repo_id]) + '?p=' + urlquote(path)
|
||||
|
||||
@@ -801,7 +796,7 @@ def file_edit_submit(request, repo_id):
|
||||
filename = os.path.basename(path).encode('utf-8')
|
||||
try:
|
||||
seafserv_threaded_rpc.put_file(repo_id, tmpfile, parent_dir,
|
||||
filename, request.user.username, head_id)
|
||||
filename, username, head_id)
|
||||
remove_tmp_file()
|
||||
return HttpResponse(json.dumps({'href': next}),
|
||||
content_type=content_type)
|
||||
|
@@ -40,7 +40,7 @@ def get_wiki_dirent(repo_id, page_name):
|
||||
cmmt = seaserv.get_commits(repo.id, 0, 1)[0]
|
||||
if cmmt is None:
|
||||
raise WikiPageMissing
|
||||
dirs = seafile_api.list_dir_by_commit_and_path(cmmt, "/")
|
||||
dirs = seafile_api.list_dir_by_commit_and_path(cmmt.id, "/")
|
||||
if dirs:
|
||||
for e in dirs:
|
||||
if stat.S_ISDIR(e.mode):
|
||||
|
Reference in New Issue
Block a user