From f9954f93f35feb20985c415e42beead0d5934204 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Tue, 16 Apr 2024 18:48:51 +0200 Subject: [PATCH] UI - Adding UI notice if watch has group options set (#2311 #2307) --- changedetectionio/flask_app.py | 7 +++++++ changedetectionio/model/Watch.py | 1 + changedetectionio/templates/edit.html | 5 +++-- changedetectionio/tests/test_group.py | 6 ++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/changedetectionio/flask_app.py b/changedetectionio/flask_app.py index e7ab0744..9fb61664 100644 --- a/changedetectionio/flask_app.py +++ b/changedetectionio/flask_app.py @@ -603,6 +603,12 @@ def changedetection_app(config=None, datastore_o=None): output = render_template("clear_all_history.html") return output + def _watch_has_tag_options_set(watch): + """This should be fixed better so that Tag is some proper Model, a tag is just a Watch also""" + for tag_uuid, tag in datastore.data['settings']['application'].get('tags', {}).items(): + if tag_uuid in watch.get('tags', []) and (tag.get('include_filters') or tag.get('subtractive_selectors')): + return True + @app.route("/edit/", methods=['GET', 'POST']) @login_optionally_required # https://stackoverflow.com/questions/42984453/wtforms-populate-form-with-data-if-data-exists @@ -773,6 +779,7 @@ def changedetection_app(config=None, datastore_o=None): has_default_notification_urls=True if len(datastore.data['settings']['application']['notification_urls']) else False, has_empty_checktime=using_default_check_time, has_extra_headers_file=len(datastore.get_all_headers_in_textfile_for_watch(uuid=uuid)) > 0, + has_special_tag_options=_watch_has_tag_options_set(watch=watch), is_html_webdriver=is_html_webdriver, jq_support=jq_support, playwright_enabled=os.getenv('PLAYWRIGHT_DRIVER_URL', False), diff --git a/changedetectionio/model/Watch.py b/changedetectionio/model/Watch.py index 044090b7..b880b916 100644 --- a/changedetectionio/model/Watch.py +++ b/changedetectionio/model/Watch.py @@ -362,6 +362,7 @@ class model(dict): # @todo bump static cache of the last timestamp so we dont need to examine the file to set a proper ''viewed'' status return snapshot_fname + @property @property def has_empty_checktime(self): # using all() + dictionary comprehension diff --git a/changedetectionio/templates/edit.html b/changedetectionio/templates/edit.html index a25fcaf5..c5493192 100644 --- a/changedetectionio/templates/edit.html +++ b/changedetectionio/templates/edit.html @@ -32,6 +32,7 @@ {% endif %} +{% set has_tag_filters_extra="WARNING: Watch has tag/groups set with special filters\n" if has_special_tag_options else '' %}
@@ -281,7 +282,7 @@ User-Agent: wonderbra 1.0") }}
{% set field = render_field(form.include_filters, rows=5, - placeholder="#example + placeholder=has_tag_filters_extra+"#example xpath://body/div/span[contains(@class, 'example-class')]", class="m-d") %} @@ -317,7 +318,7 @@ xpath://body/div/span[contains(@class, 'example-class')]",
- {{ render_field(form.subtractive_selectors, rows=5, placeholder="header + {{ render_field(form.subtractive_selectors, rows=5, placeholder=has_tag_filters_extra+"header footer nav .stockticker") }} diff --git a/changedetectionio/tests/test_group.py b/changedetectionio/tests/test_group.py index d9912a06..8904097d 100644 --- a/changedetectionio/tests/test_group.py +++ b/changedetectionio/tests/test_group.py @@ -100,6 +100,12 @@ def test_setup_group_tag(client, live_server): assert b'Should be only this' in res.data assert b'And never this' not in res.data + res = client.get( + url_for("edit_page", uuid="first"), + follow_redirects=True + ) + # 2307 the UI notice should appear in the placeholder + assert b'WARNING: Watch has tag/groups set with special filters' in res.data # RSS Group tag filter # An extra one that should be excluded