From 2ecc2ce4ec44b316fc0ed1ef10b2592220c62527 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Tue, 16 Jul 2024 16:31:07 +0200 Subject: [PATCH] Add note that watch restock is overriden --- changedetectionio/flask_app.py | 8 ++++++-- .../processors/restock_diff/__init__.py | 2 +- changedetectionio/processors/restock_diff/forms.py | 13 +++++++++++-- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/changedetectionio/flask_app.py b/changedetectionio/flask_app.py index 1105f91a3..d5e361580 100644 --- a/changedetectionio/flask_app.py +++ b/changedetectionio/flask_app.py @@ -699,8 +699,12 @@ def changedetection_app(config=None, datastore_o=None): data=default ) - # For the form widget tag uuid lookup - form.tags.datastore = datastore # in _value + # For the form widget tag UUID back to "string name" for the field + form.tags.datastore = datastore + + # Used by some forms that need to dig deeper + form.datastore = datastore + form.watch = default for p in datastore.extra_browsers: form.fetch_backend.choices.append(p) diff --git a/changedetectionio/processors/restock_diff/__init__.py b/changedetectionio/processors/restock_diff/__init__.py index b02189069..3f0be03b2 100644 --- a/changedetectionio/processors/restock_diff/__init__.py +++ b/changedetectionio/processors/restock_diff/__init__.py @@ -62,7 +62,7 @@ class Watch(BaseWatch): self['restock_settings'] = kw['default']['restock_settings'] if kw.get('default',{}).get('restock_settings') else { 'follow_price_changes': True, 'in_stock_processing' : 'in_stock_only' - } + } #@todo update def clear_watch(self): super().clear_watch() diff --git a/changedetectionio/processors/restock_diff/forms.py b/changedetectionio/processors/restock_diff/forms.py index efa66f3cb..39334aa3c 100644 --- a/changedetectionio/processors/restock_diff/forms.py +++ b/changedetectionio/processors/restock_diff/forms.py @@ -6,7 +6,6 @@ from wtforms import ( from wtforms.fields.choices import RadioField from wtforms.fields.form import FormField from wtforms.form import Form -from wtforms.validators import ValidationError from changedetectionio.forms import processor_text_json_diff_form @@ -37,7 +36,16 @@ class processor_settings_form(processor_text_json_diff_form): return 'Restock & Price Detection' def extra_form_content(self): - return """ + output = "" + + if getattr(self, 'watch', None) and getattr(self, 'datastore'): + for tag_uuid in self.watch.get('tags'): + tag = self.datastore.data['settings']['application']['tags'].get(tag_uuid, {}) + if tag.get('overrides_watch'): + # @todo - Quick and dirty, cant access 'url_for' here because its out of scope somehow + output = f"""

Note! A Group tag overrides the restock and price detection here.

""" + + output += """ {% from '_helpers.html' import render_field, render_checkbox_field, render_button %}