diff --git a/changedetectionio/fetch_site_status.py b/changedetectionio/fetch_site_status.py index 7c6687a5..44baa1d6 100644 --- a/changedetectionio/fetch_site_status.py +++ b/changedetectionio/fetch_site_status.py @@ -278,23 +278,18 @@ class perform_site_check(): logging.debug("check_unique_lines: UUID {} had unique content".format(uuid)) if changed_detected: - diff_filters = { - "add": watch.get('trigger_on_add', True), - "del": watch.get('trigger_on_del', True), - } - - if False in diff_filters.values(): # if we are supposed to filter any diff types - print("Diff Filters Active: " + str(diff_filters)) - + if watch.get("trigger_type", "all") != "all": # if we are supposed to filter any diff types # get the diff types present in the watch diff_types = watch.get_diff_types(text_content_before_ignored_filter) print("Diff components found: " + str(diff_types)) - # for each diff type, if the filter setting is false, and the diff type is present, then set the changed_detected to false - for diff_type in diff_types: - if not diff_filters[diff_type] and diff_types[diff_type]: - changed_detected = False - break # we only need to check one diff type + # Only Additions + if watch["trigger_type"] == "add" and not diff_types["add"] and diff_types["del"]: + changed_detected = False + + # Only Deletions + elif watch["trigger_type"] == "delete" and not diff_types["del"] and diff_types["add"]: + changed_detected = False # Always record the new checksum and the new text update_obj["previous_md5"] = fetched_md5 diff --git a/changedetectionio/forms.py b/changedetectionio/forms.py index 7e88b361..ad349113 100644 --- a/changedetectionio/forms.py +++ b/changedetectionio/forms.py @@ -8,7 +8,6 @@ from wtforms import ( PasswordField, RadioField, SelectField, - SelectMultipleField, StringField, SubmitField, TextAreaField, @@ -344,8 +343,7 @@ class watchForm(commonSettingsForm): check_unique_lines = BooleanField('Only trigger when new lines appear', default=False) trigger_text = StringListField('Trigger/wait for text', [validators.Optional(), ValidateListRegex()]) text_should_not_be_present = StringListField('Block change-detection if text matches', [validators.Optional(), ValidateListRegex()]) - trigger_on_add = BooleanField('Additions', default=True) - trigger_on_del = BooleanField('Deletions', default=True) + trigger_type = SelectField(u'Trigger On', choices=[("all", "Any Changes"), ("add", "Only Additions"), ("delete", "Only Deletions")], coerce=str, default="add") webdriver_js_execute_code = TextAreaField('Execute JavaScript before change detection', render_kw={"rows": "5"}, validators=[validators.Optional()]) diff --git a/changedetectionio/model/Watch.py b/changedetectionio/model/Watch.py index bb33d3a7..e49069d1 100644 --- a/changedetectionio/model/Watch.py +++ b/changedetectionio/model/Watch.py @@ -43,8 +43,7 @@ class model(dict): 'fetch_backend': None, 'extract_title_as_title': False, 'check_unique_lines': False, # On change-detected, compare against all history if its something new - 'trigger_on_add': True, # Allow a trigger if there are additions from the last snapshot - 'trigger_on_del': True, # Allow a trigger if there are deletions from the last snapshot + 'trigger_type': "all", 'proxy': None, # Preferred proxy connection # Re #110, so then if this is set to None, we know to use the default value instead # Requires setting to None on submit if it's the same as the default diff --git a/changedetectionio/templates/edit.html b/changedetectionio/templates/edit.html index 2531fa3f..acd0f5e5 100644 --- a/changedetectionio/templates/edit.html +++ b/changedetectionio/templates/edit.html @@ -157,13 +157,11 @@ User-Agent: wonderbra 1.0") }}
-
- - {{ render_checkbox_field(form.trigger_on_add, class="trigger-type") }} - {{ render_checkbox_field(form.trigger_on_del, class="trigger-type") }} +
+ {{ render_field(form.trigger_type) }} This filter only compares to the previous snapshot. This is different from the "Only trigger when new lines appear" setting which checks all previous snapshots. - This is good for filtering out notifications for only content being removed. + This is good for filtering out notifications that only are showing deleted content. (i.e A notice being removed from a website)