From 2e83b42ba9451e49848b3d2a5ac0bf73d7cbc60f Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Sat, 6 May 2017 22:43:49 -0700 Subject: [PATCH] Add blank defaults to conditions and parameters --- plexpy/__init__.py | 4 ++-- plexpy/webserve.py | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/plexpy/__init__.py b/plexpy/__init__.py index a110559e..c55d7c0f 100644 --- a/plexpy/__init__.py +++ b/plexpy/__init__.py @@ -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' ) diff --git a/plexpy/webserve.py b/plexpy/webserve.py index 67b088b8..a10ed13d 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -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))