Merge branch 'master' of github.com:ngoduykhanh/PowerDNS-Admin

This commit is contained in:
Khanh Ngo 2020-01-29 22:33:32 +07:00
commit 4cfb6ef81f
No known key found for this signature in database
GPG Key ID: A945965CD6351844
4 changed files with 22 additions and 15 deletions

View File

@ -1,3 +1,5 @@
from flask import current_app
from .base import db from .base import db
from .user import User from .user import User
from .account_user import AccountUser from .account_user import AccountUser
@ -99,7 +101,7 @@ class Account(db.Model):
return True return True
except Exception as e: except Exception as e:
db.session.rollback() db.session.rollback()
logging.error( current_app.logger.error(
'Cannot delete account {0} from DB. DETAIL: {1}'.format( 'Cannot delete account {0} from DB. DETAIL: {1}'.format(
self.username, e)) self.username, e))
return False return False
@ -140,7 +142,7 @@ class Account(db.Model):
db.session.commit() db.session.commit()
except Exception as e: except Exception as e:
db.session.rollback() db.session.rollback()
logging.error( current_app.logger.error(
'Cannot revoke user privileges on account {0}. DETAIL: {1}'. 'Cannot revoke user privileges on account {0}. DETAIL: {1}'.
format(self.name, e)) format(self.name, e))
@ -151,7 +153,7 @@ class Account(db.Model):
db.session.commit() db.session.commit()
except Exception as e: except Exception as e:
db.session.rollback() db.session.rollback()
logging.error( current_app.logger.error(
'Cannot grant user privileges to account {0}. DETAIL: {1}'. 'Cannot grant user privileges to account {0}. DETAIL: {1}'.
format(self.name, e)) format(self.name, e))
@ -177,7 +179,7 @@ class Account(db.Model):
return True return True
except Exception as e: except Exception as e:
db.session.rollback() db.session.rollback()
logging.error( current_app.logger.error(
'Cannot add user privileges on account {0}. DETAIL: {1}'. 'Cannot add user privileges on account {0}. DETAIL: {1}'.
format(self.name, e)) format(self.name, e))
return False return False
@ -194,7 +196,7 @@ class Account(db.Model):
return True return True
except Exception as e: except Exception as e:
db.session.rollback() db.session.rollback()
logging.error( current_app.logger.error(
'Cannot revoke user privileges on account {0}. DETAIL: {1}'. 'Cannot revoke user privileges on account {0}. DETAIL: {1}'.
format(self.name, e)) format(self.name, e))
return False return False

View File

@ -1,3 +1,5 @@
from flask import current_app
from .base import db from .base import db
@ -26,8 +28,8 @@ class DomainSetting(db.Model):
db.session.commit() db.session.commit()
return True return True
except Exception as e: except Exception as e:
logging.error( current_app.logger.error(
'Unable to set DomainSetting value. DETAIL: {0}'.format(e)) 'Unable to set DomainSetting value. DETAIL: {0}'.format(e))
logging.debug(traceback.format_exc()) current_app.logger.debug(traceback.format_exc())
db.session.rollback() db.session.rollback()
return False return False

View File

@ -1,3 +1,5 @@
from flask import current_app
from .base import db from .base import db
@ -36,7 +38,7 @@ class DomainTemplateRecord(db.Model):
try: try:
db.session.commit() db.session.commit()
except Exception as e: except Exception as e:
logging.error( current_app.logger.error(
'Can not update domain template table. Error: {0}'.format(e)) 'Can not update domain template table. Error: {0}'.format(e))
db.session.rollback() db.session.rollback()
return { return {

View File

@ -2,6 +2,7 @@ import sys
import pytimeparse import pytimeparse
from ast import literal_eval from ast import literal_eval
from distutils.util import strtobool from distutils.util import strtobool
from flask import current_app
from .base import db from .base import db
@ -194,9 +195,9 @@ class Setting(db.Model):
db.session.commit() db.session.commit()
return True return True
except Exception as e: except Exception as e:
logging.error('Cannot set maintenance to {0}. DETAIL: {1}'.format( current_app.logger.error('Cannot set maintenance to {0}. DETAIL: {1}'.format(
mode, e)) mode, e))
logging.debug(traceback.format_exec()) current_app.logger.debug(traceback.format_exec())
db.session.rollback() db.session.rollback()
return False return False
@ -216,9 +217,9 @@ class Setting(db.Model):
db.session.commit() db.session.commit()
return True return True
except Exception as e: except Exception as e:
logging.error('Cannot toggle setting {0}. DETAIL: {1}'.format( current_app.logger.error('Cannot toggle setting {0}. DETAIL: {1}'.format(
setting, e)) setting, e))
logging.debug(traceback.format_exec()) current_app.logger.debug(traceback.format_exec())
db.session.rollback() db.session.rollback()
return False return False
@ -236,9 +237,9 @@ class Setting(db.Model):
db.session.commit() db.session.commit()
return True return True
except Exception as e: except Exception as e:
logging.error('Cannot edit setting {0}. DETAIL: {1}'.format( current_app.logger.error('Cannot edit setting {0}. DETAIL: {1}'.format(
setting, e)) setting, e))
logging.debug(traceback.format_exec()) current_app.logger.debug(traceback.format_exec())
db.session.rollback() db.session.rollback()
return False return False
@ -252,7 +253,7 @@ class Setting(db.Model):
else: else:
return self.defaults[setting] return self.defaults[setting]
else: else:
logging.error('Unknown setting queried: {0}'.format(setting)) current_app.logger.error('Unknown setting queried: {0}'.format(setting))
def get_records_allow_to_edit(self): def get_records_allow_to_edit(self):
return list( return list(