mirror of
https://github.com/spl0k/supysonic.git
synced 2025-01-12 03:06:18 +00:00
Fix FK errors when deleting a user
This commit is contained in:
parent
724f04726e
commit
ad688a23c3
@ -37,12 +37,12 @@ class UserManager:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def delete(uid):
|
def delete(uid):
|
||||||
user = UserManager.get(uid)
|
user = UserManager.get(uid)
|
||||||
user.delete_instance()
|
user.delete_instance(recursive=True)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def delete_by_name(name):
|
def delete_by_name(name):
|
||||||
user = User.get(name=name)
|
user = User.get(name=name)
|
||||||
user.delete_instance()
|
user.delete_instance(recursive=True)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def try_auth(name, password):
|
def try_auth(name, password):
|
||||||
|
@ -104,6 +104,7 @@ class UserManagerTestCase(unittest.TestCase):
|
|||||||
# Delete existing users
|
# Delete existing users
|
||||||
for name in ["alice", "bob", "charlie"]:
|
for name in ["alice", "bob", "charlie"]:
|
||||||
user = db.User.get(name=name)
|
user = db.User.get(name=name)
|
||||||
|
db.ClientPrefs.create(user=user, client_name="tests") # test for FK handling
|
||||||
UserManager.delete(user.id)
|
UserManager.delete(user.id)
|
||||||
self.assertRaises(db.User.DoesNotExist, db.User.__getitem__, user.id)
|
self.assertRaises(db.User.DoesNotExist, db.User.__getitem__, user.id)
|
||||||
self.assertEqual(db.User.select().count(), 0)
|
self.assertEqual(db.User.select().count(), 0)
|
||||||
@ -113,6 +114,8 @@ class UserManagerTestCase(unittest.TestCase):
|
|||||||
|
|
||||||
# Delete existing users
|
# Delete existing users
|
||||||
for name in ["alice", "bob", "charlie"]:
|
for name in ["alice", "bob", "charlie"]:
|
||||||
|
user = db.User.get(name=name)
|
||||||
|
db.ClientPrefs.create(user=user, client_name="tests") # test for FK handling
|
||||||
UserManager.delete_by_name(name)
|
UserManager.delete_by_name(name)
|
||||||
self.assertFalse(db.User.select().where(db.User.name == name).exists())
|
self.assertFalse(db.User.select().where(db.User.name == name).exists())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user