Re #149 - allow empty timestamp limit for scrub operation

pull/150/head
dgtlmoon 3 years ago
parent 1c09407e24
commit 750b882546

@ -299,25 +299,28 @@ def changedetection_app(config=None, datastore_o=None):
if request.method == 'POST': if request.method == 'POST':
confirmtext = request.form.get('confirmtext') confirmtext = request.form.get('confirmtext')
limit_date = request.form.get('limit_date') limit_date = request.form.get('limit_date')
limit_timestamp = 0
try:
limit_date = limit_date.replace('T', ' ') # Re #149 - allow empty/0 timestamp limit
# I noticed chrome will show '/' but actually submit '-' if len(limit_date):
limit_date = limit_date.replace('-', '/') try:
# In the case that :ss seconds are supplied limit_date = limit_date.replace('T', ' ')
limit_date = re.sub('(\d\d:\d\d)(:\d\d)', '\\1', limit_date) # I noticed chrome will show '/' but actually submit '-'
limit_date = limit_date.replace('-', '/')
str_to_dt = datetime.datetime.strptime(limit_date, '%Y/%m/%d %H:%M') # In the case that :ss seconds are supplied
limit_timestamp = int(str_to_dt.timestamp()) limit_date = re.sub('(\d\d:\d\d)(:\d\d)', '\\1', limit_date)
if limit_timestamp > time.time(): str_to_dt = datetime.datetime.strptime(limit_date, '%Y/%m/%d %H:%M')
flash("Timestamp is in the future, cannot continue.", 'error') limit_timestamp = int(str_to_dt.timestamp())
if limit_timestamp > time.time():
flash("Timestamp is in the future, cannot continue.", 'error')
return redirect(url_for('scrub_page'))
except ValueError:
flash('Incorrect date format, cannot continue.', 'error')
return redirect(url_for('scrub_page')) return redirect(url_for('scrub_page'))
except ValueError:
flash('Incorrect date format, cannot continue.', 'error')
return redirect(url_for('scrub_page'))
if confirmtext == 'scrub': if confirmtext == 'scrub':
changes_removed = 0 changes_removed = 0
for uuid, watch in datastore.data['watching'].items(): for uuid, watch in datastore.data['watching'].items():

Loading…
Cancel
Save