mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-01 15:09:14 +00:00
Delete user option (#1979)
* Remove user all options * delete space * delete space * debug sapce
This commit is contained in:
@@ -331,6 +331,13 @@ class User(object):
|
|||||||
if settings.ENABLE_TERMS_AND_CONDITIONS:
|
if settings.ENABLE_TERMS_AND_CONDITIONS:
|
||||||
from termsandconditions.models import UserTermsAndConditions
|
from termsandconditions.models import UserTermsAndConditions
|
||||||
UserTermsAndConditions.objects.filter(username=username).delete()
|
UserTermsAndConditions.objects.filter(username=username).delete()
|
||||||
|
self.delete_user_options(username)
|
||||||
|
|
||||||
|
def delete_user_options(self, username):
|
||||||
|
"""Remove user's all options.
|
||||||
|
"""
|
||||||
|
from seahub.options.models import UserOptions
|
||||||
|
UserOptions.objects.filter(email=username).delete()
|
||||||
|
|
||||||
def get_and_delete_messages(self):
|
def get_and_delete_messages(self):
|
||||||
messages = []
|
messages = []
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
from seahub.test_utils import BaseTestCase
|
from seahub.test_utils import BaseTestCase
|
||||||
from seahub.base.accounts import User, RegistrationForm
|
from seahub.base.accounts import User, RegistrationForm
|
||||||
|
|
||||||
|
from seahub.options.models import UserOptions
|
||||||
from post_office.models import Email
|
from post_office.models import Email
|
||||||
|
|
||||||
class UserTest(BaseTestCase):
|
class UserTest(BaseTestCase):
|
||||||
@@ -16,6 +17,20 @@ class UserTest(BaseTestCase):
|
|||||||
# email = Email.objects.all()[0]
|
# email = Email.objects.all()[0]
|
||||||
# print email.html_message
|
# print email.html_message
|
||||||
|
|
||||||
|
def test_delete_user_options(self):
|
||||||
|
test_email = '123@123.com'
|
||||||
|
|
||||||
|
assert len(UserOptions.objects.filter(email=test_email)) == 0
|
||||||
|
|
||||||
|
User.objects.create_user(test_email)
|
||||||
|
UserOptions.objects.enable_server_crypto(test_email)
|
||||||
|
|
||||||
|
assert len(UserOptions.objects.filter(email=test_email)) == 1
|
||||||
|
|
||||||
|
user = User.objects.get(email=test_email)
|
||||||
|
user.delete()
|
||||||
|
|
||||||
|
assert len(UserOptions.objects.filter(email=test_email)) == 0
|
||||||
|
|
||||||
class UserPermissionsTest(BaseTestCase):
|
class UserPermissionsTest(BaseTestCase):
|
||||||
def test_permissions(self):
|
def test_permissions(self):
|
||||||
|
Reference in New Issue
Block a user