mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-09 23:20:27 +00:00
Use Account.delete_account to also handle unlinking of Users
This commit is contained in:
parent
9632898b40
commit
b4d7f66e29
@ -98,7 +98,7 @@ class Account(db.Model):
|
|||||||
db.session.commit()
|
db.session.commit()
|
||||||
return {'status': True, 'msg': 'Account updated successfully'}
|
return {'status': True, 'msg': 'Account updated successfully'}
|
||||||
|
|
||||||
def delete_account(self):
|
def delete_account(self, commit=True):
|
||||||
"""
|
"""
|
||||||
Delete an account
|
Delete an account
|
||||||
"""
|
"""
|
||||||
@ -107,7 +107,8 @@ class Account(db.Model):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
Account.query.filter(Account.name == self.name).delete()
|
Account.query.filter(Account.name == self.name).delete()
|
||||||
db.session.commit()
|
if commit:
|
||||||
|
db.session.commit()
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
@ -239,7 +240,7 @@ class Account(db.Model):
|
|||||||
continue
|
continue
|
||||||
current_app.logger.info("Deleting account for {0}".format(account_name))
|
current_app.logger.info("Deleting account for {0}".format(account_name))
|
||||||
account = Account.query.get(account_id)
|
account = Account.query.get(account_id)
|
||||||
db.session.delete(account)
|
account.delete_account(commit=False)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
current_app.logger.error(
|
current_app.logger.error(
|
||||||
'Can not delete account from DB. DETAIL: {0}'.format(e))
|
'Can not delete account from DB. DETAIL: {0}'.format(e))
|
||||||
|
Loading…
Reference in New Issue
Block a user