1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-19 18:29:23 +00:00

Redirect to wiki page when edit page, and fixed a few bugs

This commit is contained in:
zhengxie
2013-08-01 11:18:14 +08:00
parent f0bdfedd55
commit 04a75fc57c
3 changed files with 12 additions and 17 deletions

View File

@@ -191,7 +191,7 @@ def get_repo_dirents(request, repo_id, commit, path):
return ([], []) return ([], [])
else: else:
try: 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: except SearpcError, e:
raise Http404 raise Http404
# return render_error(self.request, e.msg) # return render_error(self.request, e.msg)
@@ -1487,8 +1487,8 @@ def file_revisions(request, repo_id):
def handle_download(): def handle_download():
parent_dir = os.path.dirname(path) parent_dir = os.path.dirname(path)
file_name = os.path.basename(path) file_name = os.path.basename(path)
seafdir = seafile_api.list_dir_by_commit_and_path (commit_id, \ seafdir = seafile_api.list_dir_by_commit_and_path (commit_id,
parent_dir.encode('utf-8')) parent_dir)
if not seafdir: if not seafdir:
return render_error(request) return render_error(request)

View File

@@ -736,14 +736,15 @@ def file_edit_submit(request, repo_id):
status=400, status=400,
content_type=content_type) 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')) return error_json(_(u'Permission denied'))
repo = get_repo(repo_id) repo = get_repo(repo_id)
if not repo: if not repo:
return error_json(_(u'The library does not exist.')) return error_json(_(u'The library does not exist.'))
if repo.encrypted: 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: if not repo.password_set:
return error_json(_(u'The library is encrypted.'), 'decrypt') return error_json(_(u'The library is encrypted.'), 'decrypt')
@@ -776,24 +777,18 @@ def file_edit_submit(request, repo_id):
remove_tmp_file() remove_tmp_file()
return error_json() 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: try:
gid = int(request.GET.get('gid', 0)) gid = int(request.GET.get('gid', 0))
except ValueError: except ValueError:
gid = 0 gid = 0
wiki_name = os.path.splitext(os.path.basename(path))[0] wiki_name = os.path.splitext(os.path.basename(path))[0]
next = reverse('group_wiki', args=[gid, wiki_name]) next = reverse('group_wiki', args=[gid, wiki_name])
elif request.GET.get('from', '') == 'wiki_page_new': elif req_from == 'personal_wiki_page_edit' or req_from == 'personal_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':
wiki_name = os.path.splitext(os.path.basename(path))[0] wiki_name = os.path.splitext(os.path.basename(path))[0]
next = reverse('personal_wiki', args=[wiki_name]) next = reverse('personal_wiki', args=[wiki_name])
elif request.GET.get('from', '') == 'personal_wiki_page_new':
next = reverse('personal_wiki_pages')
else: else:
next = reverse('repo_view_file', args=[repo_id]) + '?p=' + urlquote(path) 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') filename = os.path.basename(path).encode('utf-8')
try: try:
seafserv_threaded_rpc.put_file(repo_id, tmpfile, parent_dir, seafserv_threaded_rpc.put_file(repo_id, tmpfile, parent_dir,
filename, request.user.username, head_id) filename, username, head_id)
remove_tmp_file() remove_tmp_file()
return HttpResponse(json.dumps({'href': next}), return HttpResponse(json.dumps({'href': next}),
content_type=content_type) content_type=content_type)

View File

@@ -40,7 +40,7 @@ def get_wiki_dirent(repo_id, page_name):
cmmt = seaserv.get_commits(repo.id, 0, 1)[0] cmmt = seaserv.get_commits(repo.id, 0, 1)[0]
if cmmt is None: if cmmt is None:
raise WikiPageMissing 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: if dirs:
for e in dirs: for e in dirs:
if stat.S_ISDIR(e.mode): if stat.S_ISDIR(e.mode):