Populate NULL text fields after a DB update

This commit is contained in:
samwiseg00 2018-10-05 23:18:00 -04:00
parent a6e8372d47
commit 1e3a347782

View file

@ -411,7 +411,9 @@ def get_notify_agents():
return tuple(a['name'] for a in sorted(available_notification_agents(), key=lambda k: k['label'])) return tuple(a['name'] for a in sorted(available_notification_agents(), key=lambda k: k['label']))
def get_notify_actions(): def get_notify_actions(return_dict=False):
if return_dict:
return {a.pop('name'): a for a in available_notification_actions()}
return tuple(a['name'] for a in available_notification_actions()) return tuple(a['name'] for a in available_notification_actions())
@ -475,15 +477,23 @@ def get_notifier_config(notifier_id=None):
logger.error(u"Tautulli Notifiers :: Failed to get notifier config options: %s." % e) logger.error(u"Tautulli Notifiers :: Failed to get notifier config options: %s." % e)
return return
notify_actions = get_notify_actions() notify_actions = get_notify_actions(return_dict=True)
notifier_actions = {} notifier_actions = {}
notifier_text = {} notifier_text = {}
for k in result.keys(): for k in result.keys():
if k in notify_actions: if k in notify_actions:
subject = result.pop(k + '_subject')
body = result.pop(k + '_body')
if subject is None:
subject = "" if result['agent_name'] in ('scripts', 'webhook') else notify_actions[k]['subject']
if body is None:
body = "" if result['agent_name'] in ('scripts', 'webhook') else notify_actions[k]['body']
notifier_actions[k] = helpers.cast_to_int(result.pop(k)) notifier_actions[k] = helpers.cast_to_int(result.pop(k))
notifier_text[k] = {'subject': result.pop(k + '_subject'), notifier_text[k] = {'subject': subject,
'body': result.pop(k + '_body')} 'body': body}
try: try:
result['custom_conditions'] = json.loads(result['custom_conditions']) result['custom_conditions'] = json.loads(result['custom_conditions'])