1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-02 07:47:32 +00:00

Fiexed bug in library setting

This commit is contained in:
zhengxie 2013-02-26 17:41:00 +08:00
parent 1659b80eb4
commit 3a485e4a73

View File

@ -564,6 +564,17 @@ def repo_save_settings(request):
form = RepoSettingForm(request.POST)
if form.is_valid():
repo_id = form.cleaned_data['repo_id']
repo_name = form.cleaned_data['repo_name']
repo_desc = form.cleaned_data['repo_desc']
days = form.cleaned_data['days']
repo = get_repo(repo_id)
if not repo:
err_msg = _(u'Library does not exist.')
return HttpResponse(json.dumps({'error': err_msg}),
status=400, content_type=content_type)
# check permission
if request.user.org:
is_owner = True if is_org_repo_owner(
request.user.org['org_id'], repo_id, username) else False
@ -574,18 +585,14 @@ def repo_save_settings(request):
return HttpResponse(json.dumps({'error': err_msg}),
status=403, content_type=content_type)
repo_name = form.cleaned_data['repo_name']
repo_desc = form.cleaned_data['repo_desc']
days = form.cleaned_data['days']
if edit_repo(repo_id, repo_name, repo_desc, username):
return HttpResponse(json.dumps({'success': True}),
content_type=content_type)
else:
err_msg = _(u'Failed to edit repo information.')
return HttpResponse(json.dumps({'error': err_msg}),
status=500, content_type=content_type)
# Edit library info (name, descryption).
if repo.name != repo_name or repo.desc != repo_desc:
if not edit_repo(repo_id, repo_name, repo_desc, username):
err_msg = _(u'Failed to edit repo information.')
return HttpResponse(json.dumps({'error': err_msg}),
status=500, content_type=content_type)
# set library history
res = set_repo_history_limit(repo_id, days)
if res == 0:
messages.success(request, _(u'Settings saved.'))