Add blank defaults to conditions and parameters

This commit is contained in:
JonnyWong16 2017-05-06 22:43:49 -07:00
parent 42b1a0d3de
commit 2e83b42ba9
2 changed files with 12 additions and 6 deletions

View file

@ -1070,9 +1070,9 @@ def dbcheck():
# Upgrade notifiers table from earlier versions
try:
c_db.execute('SELECT custom_condition FROM notifiers')
c_db.execute('SELECT custom_conditions FROM notifiers')
except sqlite3.OperationalError:
logger.debug(u"Altering database. Updating database table custom_condition.")
logger.debug(u"Altering database. Updating database table notifiers.")
c_db.execute(
'ALTER TABLE notifiers ADD COLUMN custom_conditions TEXT'
)

View file

@ -2950,10 +2950,16 @@ class WebInterface(object):
def get_notifier_config_modal(self, notifier_id=None, **kwargs):
result = notifiers.get_notifier_config(notifier_id=notifier_id)
parameters = [
{'name': param['name'], 'type': param['type'], 'value': param['value']}
for category in common.NOTIFICATION_PARAMETERS
for param in category['parameters']
if not result['custom_conditions']:
result['custom_conditions'] = json.dumps([{'coefficient': '', 'operator': '', 'value': ''}])
if not result['custom_conditions_logic']:
result['custom_conditions_logic'] = ''
parameters = [{'name': '', 'type': '', 'value': ''}]
parameters += [
{'name': param['name'], 'type': param['type'], 'value': param['value']}
for category in common.NOTIFICATION_PARAMETERS for param in category['parameters']
]
return serve_template(templatename="notifier_config.html", notifier=result, parameters=json.dumps(parameters))