mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-21 03:18:23 +00:00
Fix multiple user options bug, handle the case repo is None when delete
This commit is contained in:
@@ -105,18 +105,23 @@ class UserOptionsManager(models.Manager):
|
|||||||
|
|
||||||
def is_user_guide_enabled(self, username):
|
def is_user_guide_enabled(self, username):
|
||||||
"""Return ``True`` if user need guide, otherwise ``False``.
|
"""Return ``True`` if user need guide, otherwise ``False``.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
- `self`:
|
- `self`:
|
||||||
- `username`:
|
- `username`:
|
||||||
"""
|
"""
|
||||||
try:
|
rst = super(UserOptionsManager, self).filter(
|
||||||
user_option = super(UserOptionsManager, self).get(
|
email=username, option_key=KEY_USER_GUIDE)
|
||||||
email=username, option_key=KEY_USER_GUIDE)
|
rst_len = len(rst)
|
||||||
return bool(int(user_option.option_val))
|
if rst_len <= 0:
|
||||||
except UserOptions.DoesNotExist:
|
|
||||||
# Assume ``user_guide`` is enabled if this optoin is not set.
|
# 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):
|
def enable_sub_lib(self, username):
|
||||||
"""
|
"""
|
||||||
|
@@ -1908,7 +1908,10 @@ def sys_repo_delete(request, repo_id):
|
|||||||
return HttpResponseRedirect(next)
|
return HttpResponseRedirect(next)
|
||||||
|
|
||||||
repo = seafile_api.get_repo(repo_id)
|
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:
|
if MULTI_TENANCY:
|
||||||
org_id = seafserv_threaded_rpc.get_org_id_by_repo_id(repo_id)
|
org_id = seafserv_threaded_rpc.get_org_id_by_repo_id(repo_id)
|
||||||
|
Reference in New Issue
Block a user