Check that a notification URL is set when sending the test notification (#300)
This commit is contained in:
@@ -452,6 +452,7 @@ def changedetection_app(config=None, datastore_o=None):
|
|||||||
update_q.put(uuid)
|
update_q.put(uuid)
|
||||||
|
|
||||||
if form.trigger_check.data:
|
if form.trigger_check.data:
|
||||||
|
if len(form.notification_urls.data):
|
||||||
n_object = {'watch_url': form.url.data.strip(),
|
n_object = {'watch_url': form.url.data.strip(),
|
||||||
'notification_urls': form.notification_urls.data,
|
'notification_urls': form.notification_urls.data,
|
||||||
'notification_title': form.notification_title.data,
|
'notification_title': form.notification_title.data,
|
||||||
@@ -459,8 +460,10 @@ def changedetection_app(config=None, datastore_o=None):
|
|||||||
'notification_format': form.notification_format.data,
|
'notification_format': form.notification_format.data,
|
||||||
}
|
}
|
||||||
notification_q.put(n_object)
|
notification_q.put(n_object)
|
||||||
|
flash('Test notification queued.')
|
||||||
|
else:
|
||||||
|
flash('No notification URLs set, cannot send test.', 'error')
|
||||||
|
|
||||||
flash('Notifications queued.')
|
|
||||||
|
|
||||||
# Diff page [edit] link should go back to diff page
|
# Diff page [edit] link should go back to diff page
|
||||||
if request.args.get("next") and request.args.get("next") == 'diff':
|
if request.args.get("next") and request.args.get("next") == 'diff':
|
||||||
@@ -527,7 +530,8 @@ def changedetection_app(config=None, datastore_o=None):
|
|||||||
datastore.data['settings']['application']['notification_urls'] = form.notification_urls.data
|
datastore.data['settings']['application']['notification_urls'] = form.notification_urls.data
|
||||||
datastore.data['settings']['application']['base_url'] = form.base_url.data
|
datastore.data['settings']['application']['base_url'] = form.base_url.data
|
||||||
|
|
||||||
if form.trigger_check.data and len(form.notification_urls.data):
|
if form.trigger_check.data:
|
||||||
|
if len(form.notification_urls.data):
|
||||||
n_object = {'watch_url': "Test from changedetection.io!",
|
n_object = {'watch_url': "Test from changedetection.io!",
|
||||||
'notification_urls': form.notification_urls.data,
|
'notification_urls': form.notification_urls.data,
|
||||||
'notification_title': form.notification_title.data,
|
'notification_title': form.notification_title.data,
|
||||||
@@ -535,7 +539,9 @@ def changedetection_app(config=None, datastore_o=None):
|
|||||||
'notification_format': form.notification_format.data,
|
'notification_format': form.notification_format.data,
|
||||||
}
|
}
|
||||||
notification_q.put(n_object)
|
notification_q.put(n_object)
|
||||||
flash('Notifications queued.')
|
flash('Test notification queued.')
|
||||||
|
else:
|
||||||
|
flash('No notification URLs set, cannot send test.', 'error')
|
||||||
|
|
||||||
if form.password.encrypted_password:
|
if form.password.encrypted_password:
|
||||||
datastore.data['settings']['application']['password'] = form.password.encrypted_password
|
datastore.data['settings']['application']['password'] = form.password.encrypted_password
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ def test_check_notification(client, live_server):
|
|||||||
follow_redirects=True
|
follow_redirects=True
|
||||||
)
|
)
|
||||||
assert b"Updated watch." in res.data
|
assert b"Updated watch." in res.data
|
||||||
assert b"Notifications queued" in res.data
|
assert b"Test notification queued" in res.data
|
||||||
|
|
||||||
# Hit the edit page, be sure that we saved it
|
# Hit the edit page, be sure that we saved it
|
||||||
res = client.get(
|
res = client.get(
|
||||||
@@ -136,7 +136,7 @@ def test_check_notification(client, live_server):
|
|||||||
)
|
)
|
||||||
assert b"Settings updated." in res.data
|
assert b"Settings updated." in res.data
|
||||||
# Re #143 - should not see this if we didnt hit the test box
|
# Re #143 - should not see this if we didnt hit the test box
|
||||||
assert b"Notifications queued" not in res.data
|
assert b"Test notification queued" not in res.data
|
||||||
|
|
||||||
# Trigger a check
|
# Trigger a check
|
||||||
client.get(url_for("api_watch_checknow"), follow_redirects=True)
|
client.get(url_for("api_watch_checknow"), follow_redirects=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user