|
|
@ -519,7 +519,7 @@ def changedetection_app(config=None, datastore_o=None):
|
|
|
|
def edit_page(uuid):
|
|
|
|
def edit_page(uuid):
|
|
|
|
from changedetectionio import forms
|
|
|
|
from changedetectionio import forms
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using_default_check_time = True
|
|
|
|
# More for testing, possible to return the first/only
|
|
|
|
# More for testing, possible to return the first/only
|
|
|
|
if not datastore.data['watching'].keys():
|
|
|
|
if not datastore.data['watching'].keys():
|
|
|
|
flash("No watches to edit", "error")
|
|
|
|
flash("No watches to edit", "error")
|
|
|
@ -532,27 +532,39 @@ def changedetection_app(config=None, datastore_o=None):
|
|
|
|
flash("No watch with the UUID %s found." % (uuid), "error")
|
|
|
|
flash("No watch with the UUID %s found." % (uuid), "error")
|
|
|
|
return redirect(url_for('index'))
|
|
|
|
return redirect(url_for('index'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# be sure we update with a copy instead of accidently editing the live object by reference
|
|
|
|
|
|
|
|
default = deepcopy(datastore.data['watching'][uuid])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Show system wide default if nothing configured
|
|
|
|
|
|
|
|
if datastore.data['watching'][uuid]['fetch_backend'] is None:
|
|
|
|
|
|
|
|
default['fetch_backend'] = datastore.data['settings']['application']['fetch_backend']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Show system wide default if nothing configured
|
|
|
|
|
|
|
|
if all(value == 0 or value == None for value in datastore.data['watching'][uuid]['time_between_check'].values()):
|
|
|
|
|
|
|
|
default['time_between_check'] = deepcopy(datastore.data['settings']['requests']['time_between_check'])
|
|
|
|
|
|
|
|
|
|
|
|
form = forms.watchForm(formdata=request.form if request.method == 'POST' else None,
|
|
|
|
form = forms.watchForm(formdata=request.form if request.method == 'POST' else None,
|
|
|
|
data=datastore.data['watching'][uuid]
|
|
|
|
data=default
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if request.method == 'GET':
|
|
|
|
|
|
|
|
# Set some defaults that refer to the main config when None, we do the same in POST,
|
|
|
|
|
|
|
|
# probably there should be a nice little handler for this.
|
|
|
|
|
|
|
|
if datastore.data['watching'][uuid]['fetch_backend'] is None:
|
|
|
|
|
|
|
|
form.fetch_backend.data = datastore.data['settings']['application']['fetch_backend']
|
|
|
|
|
|
|
|
if datastore.data['watching'][uuid]['minutes_between_check'] is None:
|
|
|
|
|
|
|
|
form.minutes_between_check.data = datastore.data['settings']['requests']['minutes_between_check']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if request.method == 'POST' and form.validate():
|
|
|
|
if request.method == 'POST' and form.validate():
|
|
|
|
|
|
|
|
extra_update_obj = {}
|
|
|
|
|
|
|
|
|
|
|
|
# Re #110, if they submit the same as the default value, set it to None, so we continue to follow the default
|
|
|
|
# Re #110, if they submit the same as the default value, set it to None, so we continue to follow the default
|
|
|
|
if form.minutes_between_check.data == datastore.data['settings']['requests']['minutes_between_check']:
|
|
|
|
# Assume we use the default value, unless something relevant is different, then use the form value
|
|
|
|
form.minutes_between_check.data = None
|
|
|
|
# values could be None, 0 etc.
|
|
|
|
|
|
|
|
# Set to None unless the next for: says that something is different
|
|
|
|
|
|
|
|
extra_update_obj['time_between_check'] = dict.fromkeys(form.time_between_check.data)
|
|
|
|
|
|
|
|
for k, v in form.time_between_check.data.items():
|
|
|
|
|
|
|
|
if v and v != datastore.data['settings']['requests']['time_between_check'][k]:
|
|
|
|
|
|
|
|
extra_update_obj['time_between_check'] = form.time_between_check.data
|
|
|
|
|
|
|
|
using_default_check_time = False
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Use the default if its the same as system wide
|
|
|
|
if form.fetch_backend.data == datastore.data['settings']['application']['fetch_backend']:
|
|
|
|
if form.fetch_backend.data == datastore.data['settings']['application']['fetch_backend']:
|
|
|
|
form.fetch_backend.data = None
|
|
|
|
extra_update_obj['fetch_backend'] = None
|
|
|
|
|
|
|
|
|
|
|
|
extra_update_obj = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Notification URLs
|
|
|
|
# Notification URLs
|
|
|
|
datastore.data['watching'][uuid]['notification_urls'] = form.notification_urls.data
|
|
|
|
datastore.data['watching'][uuid]['notification_urls'] = form.notification_urls.data
|
|
|
@ -578,7 +590,7 @@ def changedetection_app(config=None, datastore_o=None):
|
|
|
|
|
|
|
|
|
|
|
|
# Re #286 - We wait for syncing new data to disk in another thread every 60 seconds
|
|
|
|
# Re #286 - We wait for syncing new data to disk in another thread every 60 seconds
|
|
|
|
# But in the case something is added we should save straight away
|
|
|
|
# But in the case something is added we should save straight away
|
|
|
|
datastore.sync_to_json()
|
|
|
|
datastore.needs_write_urgent = True
|
|
|
|
|
|
|
|
|
|
|
|
# Queue the watch for immediate recheck
|
|
|
|
# Queue the watch for immediate recheck
|
|
|
|
update_q.put(uuid)
|
|
|
|
update_q.put(uuid)
|
|
|
@ -597,12 +609,12 @@ def changedetection_app(config=None, datastore_o=None):
|
|
|
|
if request.method == 'POST' and not form.validate():
|
|
|
|
if request.method == 'POST' and not form.validate():
|
|
|
|
flash("An error occurred, please see below.", "error")
|
|
|
|
flash("An error occurred, please see below.", "error")
|
|
|
|
|
|
|
|
|
|
|
|
has_empty_checktime = datastore.data['watching'][uuid].has_empty_checktime
|
|
|
|
|
|
|
|
output = render_template("edit.html",
|
|
|
|
output = render_template("edit.html",
|
|
|
|
uuid=uuid,
|
|
|
|
uuid=uuid,
|
|
|
|
watch=datastore.data['watching'][uuid],
|
|
|
|
watch=datastore.data['watching'][uuid],
|
|
|
|
form=form,
|
|
|
|
form=form,
|
|
|
|
has_empty_checktime=has_empty_checktime,
|
|
|
|
has_empty_checktime=using_default_check_time,
|
|
|
|
current_base_url=datastore.data['settings']['application']['base_url'],
|
|
|
|
current_base_url=datastore.data['settings']['application']['base_url'],
|
|
|
|
emailprefix=os.getenv('NOTIFICATION_MAIL_BUTTON_PREFIX', False)
|
|
|
|
emailprefix=os.getenv('NOTIFICATION_MAIL_BUTTON_PREFIX', False)
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -632,15 +644,15 @@ def changedetection_app(config=None, datastore_o=None):
|
|
|
|
if form.validate():
|
|
|
|
if form.validate():
|
|
|
|
datastore.data['settings']['application'].update(form.data['application'])
|
|
|
|
datastore.data['settings']['application'].update(form.data['application'])
|
|
|
|
datastore.data['settings']['requests'].update(form.data['requests'])
|
|
|
|
datastore.data['settings']['requests'].update(form.data['requests'])
|
|
|
|
datastore.needs_write = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not os.getenv("SALTED_PASS", False) and len(form.application.form.password.encrypted_password):
|
|
|
|
if not os.getenv("SALTED_PASS", False) and len(form.application.form.password.encrypted_password):
|
|
|
|
datastore.data['settings']['application']['password'] = form.application.form.password.encrypted_password
|
|
|
|
datastore.data['settings']['application']['password'] = form.application.form.password.encrypted_password
|
|
|
|
datastore.needs_write = True
|
|
|
|
datastore.needs_write_urgent = True
|
|
|
|
flash("Password protection enabled.", 'notice')
|
|
|
|
flash("Password protection enabled.", 'notice')
|
|
|
|
flask_login.logout_user()
|
|
|
|
flask_login.logout_user()
|
|
|
|
return redirect(url_for('index'))
|
|
|
|
return redirect(url_for('index'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
datastore.needs_write_urgent = True
|
|
|
|
flash("Settings updated.")
|
|
|
|
flash("Settings updated.")
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
@ -1177,7 +1189,7 @@ def ticker_thread_check_time_launch_checks():
|
|
|
|
now = time.time()
|
|
|
|
now = time.time()
|
|
|
|
|
|
|
|
|
|
|
|
recheck_time_minimum_seconds = int(os.getenv('MINIMUM_SECONDS_RECHECK_TIME', 60))
|
|
|
|
recheck_time_minimum_seconds = int(os.getenv('MINIMUM_SECONDS_RECHECK_TIME', 60))
|
|
|
|
recheck_time_system_seconds = int(copied_datastore.data['settings']['requests']['minutes_between_check']) * 60
|
|
|
|
recheck_time_system_seconds = datastore.threshold_seconds
|
|
|
|
|
|
|
|
|
|
|
|
for uuid, watch in copied_datastore.data['watching'].items():
|
|
|
|
for uuid, watch in copied_datastore.data['watching'].items():
|
|
|
|
|
|
|
|
|
|
|
@ -1187,8 +1199,9 @@ def ticker_thread_check_time_launch_checks():
|
|
|
|
|
|
|
|
|
|
|
|
# If they supplied an individual entry minutes to threshold.
|
|
|
|
# If they supplied an individual entry minutes to threshold.
|
|
|
|
threshold = now
|
|
|
|
threshold = now
|
|
|
|
if watch.threshold_seconds:
|
|
|
|
watch_threshold_seconds = watch.threshold_seconds()
|
|
|
|
threshold -= watch.threshold_seconds
|
|
|
|
if watch_threshold_seconds:
|
|
|
|
|
|
|
|
threshold -= watch_threshold_seconds
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
threshold -= recheck_time_system_seconds
|
|
|
|
threshold -= recheck_time_system_seconds
|
|
|
|
|
|
|
|
|
|
|
|