Ability for watch to use a more obvious system default fetcher (#1320)

pull/1325/head
dgtlmoon 2 years ago
parent 7c5e2d00af
commit fba719ab8d

@ -571,6 +571,8 @@ def changedetection_app(config=None, datastore_o=None):
data=default, data=default,
) )
form.fetch_backend.choices.append(("system", 'System settings default'))
# form.browser_steps[0] can be assumed that we 'goto url' first # form.browser_steps[0] can be assumed that we 'goto url' first
if datastore.proxy_list is None: if datastore.proxy_list is None:
@ -599,10 +601,6 @@ def changedetection_app(config=None, datastore_o=None):
using_default_check_time = False using_default_check_time = False
break break
# Use the default if it's the same as system-wide.
if form.fetch_backend.data == datastore.data['settings']['application']['fetch_backend']:
extra_update_obj['fetch_backend'] = None
# Ignore text # Ignore text
@ -652,8 +650,10 @@ def changedetection_app(config=None, datastore_o=None):
watch = datastore.data['watching'].get(uuid) watch = datastore.data['watching'].get(uuid)
system_uses_webdriver = datastore.data['settings']['application']['fetch_backend'] == 'html_webdriver' system_uses_webdriver = datastore.data['settings']['application']['fetch_backend'] == 'html_webdriver'
is_html_webdriver = True if watch.get('fetch_backend') == 'html_webdriver' or (
watch.get('fetch_backend', None) is None and system_uses_webdriver) else False is_html_webdriver = False
if (watch.get('fetch_backend') == 'system' and system_uses_webdriver) or watch.get('fetch_backend') == 'html_requests':
is_html_webdriver = True
output = render_template("edit.html", output = render_template("edit.html",
browser_steps_config=browser_step_ui_config, browser_steps_config=browser_step_ui_config,

@ -92,8 +92,7 @@ class perform_site_check():
# Pluggable content fetcher # Pluggable content fetcher
prefer_backend = watch.get_fetch_backend prefer_backend = watch.get_fetch_backend
# @todo move this to Watch model get_fetch_backend if not prefer_backend or prefer_backend == 'system':
if not prefer_backend:
prefer_backend = self.datastore.data['settings']['application']['fetch_backend'] prefer_backend = self.datastore.data['settings']['application']['fetch_backend']
if hasattr(content_fetcher, prefer_backend): if hasattr(content_fetcher, prefer_backend):

@ -138,7 +138,7 @@ class ValidateContentFetcherIsReady(object):
from changedetectionio import content_fetcher from changedetectionio import content_fetcher
# Better would be a radiohandler that keeps a reference to each class # Better would be a radiohandler that keeps a reference to each class
if field.data is not None: if field.data is not None and field.data != 'system':
klass = getattr(content_fetcher, field.data) klass = getattr(content_fetcher, field.data)
some_object = klass() some_object = klass()
try: try:
@ -345,6 +345,7 @@ class quickWatchForm(Form):
edit_and_watch_submit_button = SubmitField('Edit > Watch', render_kw={"class": "pure-button pure-button-primary"}) edit_and_watch_submit_button = SubmitField('Edit > Watch', render_kw={"class": "pure-button pure-button-primary"})
# Common to a single watch and the global settings # Common to a single watch and the global settings
class commonSettingsForm(Form): class commonSettingsForm(Form):
notification_urls = StringListField('Notification URL List', validators=[validators.Optional(), ValidateAppRiseServers()]) notification_urls = StringListField('Notification URL List', validators=[validators.Optional(), ValidateAppRiseServers()])

@ -1,7 +1,7 @@
$(document).ready(function() { $(document).ready(function () {
function toggle() { function toggle() {
if ($('input[name="fetch_backend"]:checked').val() == 'html_webdriver') { if ($('input[name="fetch_backend"]:checked').val() == 'html_webdriver') {
if(playwright_enabled) { if (playwright_enabled) {
// playwright supports headers, so hide everything else // playwright supports headers, so hide everything else
// See #664 // See #664
$('#requests-override-options #request-method').hide(); $('#requests-override-options #request-method').hide();
@ -14,9 +14,14 @@ $(document).ready(function() {
$('#requests-override-options').hide(); $('#requests-override-options').hide();
} }
$('#webdriver-override-options').show(); $('#webdriver-override-options').show();
} else if ($('input[name="fetch_backend"]:checked').val() == 'system') {
$('#requests-override-options #request-method').hide();
$('#requests-override-options #request-body').hide();
$('#ignore-status-codes-option').hide();
$('#requests-override-options').hide();
$('#webdriver-override-options').hide();
} else { } else {
$('#requests-override-options').show(); $('#requests-override-options').show();

Loading…
Cancel
Save