'Mark all viewed' button was missing in this version, added test also. (#652)
This commit is contained in:
@@ -413,11 +413,13 @@ def changedetection_app(config=None, datastore_o=None):
|
|||||||
tags=existing_tags,
|
tags=existing_tags,
|
||||||
active_tag=limit_tag,
|
active_tag=limit_tag,
|
||||||
app_rss_token=datastore.data['settings']['application']['rss_access_token'],
|
app_rss_token=datastore.data['settings']['application']['rss_access_token'],
|
||||||
has_unviewed=datastore.data['has_unviewed'],
|
has_unviewed=datastore.has_unviewed,
|
||||||
# Don't link to hosting when we're on the hosting environment
|
# Don't link to hosting when we're on the hosting environment
|
||||||
hosted_sticky=os.getenv("SALTED_PASS", False) == False,
|
hosted_sticky=os.getenv("SALTED_PASS", False) == False,
|
||||||
guid=datastore.data['app_guid'],
|
guid=datastore.data['app_guid'],
|
||||||
queued_uuids=update_q.queue)
|
queued_uuids=update_q.queue)
|
||||||
|
|
||||||
|
|
||||||
if session.get('share-link'):
|
if session.get('share-link'):
|
||||||
del(session['share-link'])
|
del(session['share-link'])
|
||||||
return output
|
return output
|
||||||
@@ -746,15 +748,14 @@ def changedetection_app(config=None, datastore_o=None):
|
|||||||
return output
|
return output
|
||||||
|
|
||||||
# Clear all statuses, so we do not see the 'unviewed' class
|
# Clear all statuses, so we do not see the 'unviewed' class
|
||||||
@app.route("/api/mark-all-viewed", methods=['GET'])
|
@app.route("/form/mark-all-viewed", methods=['GET'])
|
||||||
@login_required
|
@login_required
|
||||||
def mark_all_viewed():
|
def mark_all_viewed():
|
||||||
|
|
||||||
# Save the current newest history as the most recently viewed
|
# Save the current newest history as the most recently viewed
|
||||||
for watch_uuid, watch in datastore.data['watching'].items():
|
for watch_uuid, watch in datastore.data['watching'].items():
|
||||||
datastore.set_last_viewed(watch_uuid, watch.newest_history_key)
|
datastore.set_last_viewed(watch_uuid, int(time.time()))
|
||||||
|
|
||||||
flash("Cleared all statuses.")
|
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
@app.route("/diff/<string:uuid>", methods=['GET'])
|
@app.route("/diff/<string:uuid>", methods=['GET'])
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class model(dict):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def viewed(self):
|
def viewed(self):
|
||||||
if int(self.newest_history_key) <= int(self['last_viewed']):
|
if int(self['last_viewed']) >= int(self.newest_history_key) :
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ class ChangeDetectionStore:
|
|||||||
save_data_thread = threading.Thread(target=self.save_datastore).start()
|
save_data_thread = threading.Thread(target=self.save_datastore).start()
|
||||||
|
|
||||||
def set_last_viewed(self, uuid, timestamp):
|
def set_last_viewed(self, uuid, timestamp):
|
||||||
|
logging.debug("Setting watch UUID: {} last viewed to {}".format(uuid, int(timestamp)))
|
||||||
self.data['watching'][uuid].update({'last_viewed': int(timestamp)})
|
self.data['watching'][uuid].update({'last_viewed': int(timestamp)})
|
||||||
self.needs_write = True
|
self.needs_write = True
|
||||||
|
|
||||||
@@ -165,20 +166,20 @@ class ChangeDetectionStore:
|
|||||||
seconds += x * n
|
seconds += x * n
|
||||||
return max(seconds, minimum_seconds_recheck_time)
|
return max(seconds, minimum_seconds_recheck_time)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def has_unviewed(self):
|
||||||
|
for uuid, watch in self.__data['watching'].items():
|
||||||
|
if watch.viewed == False:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def data(self):
|
def data(self):
|
||||||
has_unviewed = False
|
has_unviewed = False
|
||||||
for uuid, watch in self.__data['watching'].items():
|
for uuid, watch in self.__data['watching'].items():
|
||||||
#self.__data['watching'][uuid]['viewed']=True
|
|
||||||
# if int(watch.newest_history_key) <= int(watch['last_viewed']):
|
|
||||||
# self.__data['watching'][uuid]['viewed'] = True
|
|
||||||
|
|
||||||
# else:
|
|
||||||
# self.__data['watching'][uuid]['viewed'] = False
|
|
||||||
# has_unviewed = True
|
|
||||||
|
|
||||||
# #106 - Be sure this is None on empty string, False, None, etc
|
# #106 - Be sure this is None on empty string, False, None, etc
|
||||||
# Default var for fetch_backend
|
# Default var for fetch_backend
|
||||||
|
# @todo this may not be needed anymore, or could be easily removed
|
||||||
if not self.__data['watching'][uuid]['fetch_backend']:
|
if not self.__data['watching'][uuid]['fetch_backend']:
|
||||||
self.__data['watching'][uuid]['fetch_backend'] = self.__data['settings']['application']['fetch_backend']
|
self.__data['watching'][uuid]['fetch_backend'] = self.__data['settings']['application']['fetch_backend']
|
||||||
|
|
||||||
@@ -187,8 +188,6 @@ class ChangeDetectionStore:
|
|||||||
if not self.__data['settings']['application']['base_url']:
|
if not self.__data['settings']['application']['base_url']:
|
||||||
self.__data['settings']['application']['base_url'] = env_base_url.strip('" ')
|
self.__data['settings']['application']['base_url'] = env_base_url.strip('" ')
|
||||||
|
|
||||||
self.__data['has_unviewed'] = has_unviewed
|
|
||||||
|
|
||||||
return self.__data
|
return self.__data
|
||||||
|
|
||||||
def get_all_tags(self):
|
def get_all_tags(self):
|
||||||
|
|||||||
@@ -3,14 +3,15 @@
|
|||||||
import time
|
import time
|
||||||
from flask import url_for
|
from flask import url_for
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
from . util import set_original_response, set_modified_response, live_server_setup
|
from .util import set_original_response, set_modified_response, live_server_setup
|
||||||
|
|
||||||
sleep_time_for_fetch_thread = 3
|
sleep_time_for_fetch_thread = 3
|
||||||
|
|
||||||
|
|
||||||
# Basic test to check inscriptus is not adding return line chars, basically works etc
|
# Basic test to check inscriptus is not adding return line chars, basically works etc
|
||||||
def test_inscriptus():
|
def test_inscriptus():
|
||||||
from inscriptis import get_text
|
from inscriptis import get_text
|
||||||
html_content="<html><body>test!<br/>ok man</body></html>"
|
html_content = "<html><body>test!<br/>ok man</body></html>"
|
||||||
stripped_text_from_html = get_text(html_content)
|
stripped_text_from_html = get_text(html_content)
|
||||||
assert stripped_text_from_html == 'test!\nok man'
|
assert stripped_text_from_html == 'test!\nok man'
|
||||||
|
|
||||||
@@ -101,7 +102,8 @@ def test_check_basic_change_detection_functionality(client, live_server):
|
|||||||
# It should report nothing found (no new 'unviewed' class)
|
# It should report nothing found (no new 'unviewed' class)
|
||||||
res = client.get(url_for("index"))
|
res = client.get(url_for("index"))
|
||||||
assert b'unviewed' not in res.data
|
assert b'unviewed' not in res.data
|
||||||
assert b'head title' not in res.data # Should not be present because this is off by default
|
assert b'Mark all viewed' not in res.data
|
||||||
|
assert b'head title' not in res.data # Should not be present because this is off by default
|
||||||
assert b'test-endpoint' in res.data
|
assert b'test-endpoint' in res.data
|
||||||
|
|
||||||
set_original_response()
|
set_original_response()
|
||||||
@@ -109,7 +111,8 @@ def test_check_basic_change_detection_functionality(client, live_server):
|
|||||||
# Enable auto pickup of <title> in settings
|
# Enable auto pickup of <title> in settings
|
||||||
res = client.post(
|
res = client.post(
|
||||||
url_for("settings_page"),
|
url_for("settings_page"),
|
||||||
data={"application-extract_title_as_title": "1", "requests-time_between_check-minutes": 180, 'application-fetch_backend': "html_requests"},
|
data={"application-extract_title_as_title": "1", "requests-time_between_check-minutes": 180,
|
||||||
|
'application-fetch_backend': "html_requests"},
|
||||||
follow_redirects=True
|
follow_redirects=True
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -118,11 +121,18 @@ def test_check_basic_change_detection_functionality(client, live_server):
|
|||||||
|
|
||||||
res = client.get(url_for("index"))
|
res = client.get(url_for("index"))
|
||||||
assert b'unviewed' in res.data
|
assert b'unviewed' in res.data
|
||||||
|
assert b'Mark all viewed' in res.data
|
||||||
|
|
||||||
# It should have picked up the <title>
|
# It should have picked up the <title>
|
||||||
assert b'head title' in res.data
|
assert b'head title' in res.data
|
||||||
|
|
||||||
|
# hit the mark all viewed link
|
||||||
|
res = client.get(url_for("mark_all_viewed"), follow_redirects=True)
|
||||||
|
|
||||||
|
assert b'Mark all viewed' not in res.data
|
||||||
|
assert b'unviewed' not in res.data
|
||||||
|
|
||||||
#
|
#
|
||||||
# Cleanup everything
|
# Cleanup everything
|
||||||
res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
|
res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True)
|
||||||
assert b'Deleted' in res.data
|
assert b'Deleted' in res.data
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user