From dca918cf1d0486fe94ddc9ecb786a9ec713d5430 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Tue, 16 Jul 2024 14:51:37 +0200 Subject: [PATCH] label changes --- changedetectionio/blueprint/tags/__init__.py | 1 + .../processors/restock_diff/__init__.py | 3 +- .../processors/restock_diff/forms.py | 36 ++++++++++--------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/changedetectionio/blueprint/tags/__init__.py b/changedetectionio/blueprint/tags/__init__.py index 2c18d192d..4b6d40ca8 100644 --- a/changedetectionio/blueprint/tags/__init__.py +++ b/changedetectionio/blueprint/tags/__init__.py @@ -132,6 +132,7 @@ def construct_blueprint(datastore: ChangeDetectionStore):
{{ render_checkbox_field(form.overrides_watch) }} + Used for watches in "Restock & Price detection" mode
""" diff --git a/changedetectionio/processors/restock_diff/__init__.py b/changedetectionio/processors/restock_diff/__init__.py index 785668be0..b02189069 100644 --- a/changedetectionio/processors/restock_diff/__init__.py +++ b/changedetectionio/processors/restock_diff/__init__.py @@ -60,7 +60,8 @@ class Watch(BaseWatch): self['restock'] = Restock(kw['default']['restock']) if kw.get('default') and kw['default'].get('restock') else Restock() self['restock_settings'] = kw['default']['restock_settings'] if kw.get('default',{}).get('restock_settings') else { - 'follow_price_changes': True + 'follow_price_changes': True, + 'in_stock_processing' : 'in_stock_only' } def clear_watch(self): diff --git a/changedetectionio/processors/restock_diff/forms.py b/changedetectionio/processors/restock_diff/forms.py index 825edff3f..efa66f3cb 100644 --- a/changedetectionio/processors/restock_diff/forms.py +++ b/changedetectionio/processors/restock_diff/forms.py @@ -1,19 +1,26 @@ - from wtforms import ( BooleanField, validators, FloatField ) +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 + + class RestockSettingsForm(Form): -# Could be both, "in_stock_only" either - in_stock_only = BooleanField('Only trigger when product goes BACK to in-stock', default=True) - price_change_min = FloatField('Minimum amount to trigger notification', [validators.Optional()], + in_stock_processing = RadioField(label='Re-stock detection', choices=[ + ('in_stock_only', "In Stock only (Out Of Stock -> In Stock only)"), + ('all_changes', "Any availability changes"), + ('off', "Off, don't follow availability/restock"), + ], default="in_stock_only") + + price_change_min = FloatField('Below price to trigger notification', [validators.Optional()], render_kw={"placeholder": "No limit", "size": "10"}) - price_change_max = FloatField('Maximum amount to trigger notification', [validators.Optional()], + price_change_max = FloatField('Above price to trigger notification', [validators.Optional()], render_kw={"placeholder": "No limit", "size": "10"}) price_change_threshold_percent = FloatField('Threshold in % for price changes since the original price', validators=[ @@ -24,10 +31,8 @@ class RestockSettingsForm(Form): follow_price_changes = BooleanField('Follow price changes', default=True) class processor_settings_form(processor_text_json_diff_form): - restock_settings = FormField(RestockSettingsForm) - def extra_tab_content(self): return 'Restock & Price Detection' @@ -36,35 +41,32 @@ class processor_settings_form(processor_text_json_diff_form): {% from '_helpers.html' import render_field, render_checkbox_field, render_button %}
-
- {{ render_checkbox_field(form.restock_settings.in_stock_only) }} - Only trigger re-stock notification when page changes from out of stock to back in stock +
+ {{ render_field(form.restock_settings.in_stock_processing) }}
{{ render_checkbox_field(form.restock_settings.follow_price_changes) }} Changes in price should trigger a notification -
- When OFF - Only care about restock detection
{{ render_field(form.restock_settings.price_change_min, placeholder=watch.get('restock', {}).get('price')) }} - Minimum amount, only trigger a change when the price is less than this amount. + Minimum amount, Trigger a change/notification when the price drops below this value.
{{ render_field(form.restock_settings.price_change_max, placeholder=watch.get('restock', {}).get('price')) }} - Maximum amount, only trigger a change when the price is more than this amount. + Maximum amount, Trigger a change/notification when the price rises above this value.
{{ render_field(form.restock_settings.price_change_threshold_percent) }} - Price must change more than this % to trigger a change.
+ Price must change more than this % to trigger a change since the first check.
For example, If the product is $1,000 USD originally, 2% would mean it has to change more than $20 since the first check.
- """ \ No newline at end of file + """