1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-21 11:27:18 +00:00

Fix multiple user options bug, handle the case repo is None when delete

This commit is contained in:
zhengxie
2015-12-04 11:15:34 +08:00
parent 4a5f27052a
commit f3732d87b6
2 changed files with 16 additions and 8 deletions

View File

@@ -105,18 +105,23 @@ class UserOptionsManager(models.Manager):
def is_user_guide_enabled(self, username):
"""Return ``True`` if user need guide, otherwise ``False``.
Arguments:
- `self`:
- `username`:
"""
try:
user_option = super(UserOptionsManager, self).get(
email=username, option_key=KEY_USER_GUIDE)
return bool(int(user_option.option_val))
except UserOptions.DoesNotExist:
rst = super(UserOptionsManager, self).filter(
email=username, option_key=KEY_USER_GUIDE)
rst_len = len(rst)
if rst_len <= 0:
# Assume ``user_guide`` is enabled if this optoin is not set.
return True
return True
elif rst_len == 1:
return bool(int(rst[0].option_val))
else:
for i in range(rst_len - 1):
rst[i].delete()
return bool(int(rst[rst_len - 1].option_val))
def enable_sub_lib(self, username):
"""

View File

@@ -1908,7 +1908,10 @@ def sys_repo_delete(request, repo_id):
return HttpResponseRedirect(next)
repo = seafile_api.get_repo(repo_id)
repo_name = repo.name
if repo: # Handle the case that repo is `None`.
repo_name = repo.name
else:
repo_name = ''
if MULTI_TENANCY:
org_id = seafserv_threaded_rpc.get_org_id_by_repo_id(repo_id)