@ -4,10 +4,12 @@ from wtforms import (
validators ,
validators ,
FloatField
FloatField
)
)
from wtforms . fields . form import FormField
from wtforms . form import Form
from changedetectionio . forms import processor_text_json_diff_form
from changedetectionio . forms import processor_text_json_diff_form
class RestockSettingsForm ( Form ) :
class processor_settings_form ( processor_text_json_diff_form ) :
# Could be both, "in_stock_only" either
in_stock_only = BooleanField ( ' Only trigger when product goes BACK to in-stock ' , default = True )
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 ( ) ] ,
price_change_min = FloatField ( ' Minimum amount to trigger notification ' , [ validators . Optional ( ) ] ,
render_kw = { " placeholder " : " No limit " , " size " : " 10 " } )
render_kw = { " placeholder " : " No limit " , " size " : " 10 " } )
@ -19,7 +21,12 @@ class processor_settings_form(processor_text_json_diff_form):
validators . NumberRange ( min = 0 , max = 100 , message = " Should be between 0 and 100 " ) ,
validators . NumberRange ( min = 0 , max = 100 , message = " Should be between 0 and 100 " ) ,
] , render_kw = { " placeholder " : " 0 % " , " size " : " 5 " } )
] , render_kw = { " placeholder " : " 0 % " , " size " : " 5 " } )
follow_price_changes = BooleanField ( ' Follow price changes ' , default = False )
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 ) :
def extra_tab_content ( self ) :
return ' Restock & Price Detection '
return ' Restock & Price Detection '
@ -33,29 +40,28 @@ class processor_settings_form(processor_text_json_diff_form):
} ) ;
} ) ;
< / script >
< / script >
< fieldset id = " restock-fieldset-price-group " >
< fieldset id = " restock-fieldset-price-group " >
< div class = " pure-control-group " >
< div class = " pure-control-group " >
< fieldset class = " pure-group " >
< fieldset class = " pure-group " >
{ { render_checkbox_field ( form . in_stock_only) } }
{ { render_checkbox_field ( form . restock_settings. in_stock_only) } }
< span class = " pure-form-message-inline " > Only trigger re - stock notification when page changes from < strong > out of stock < / strong > to < strong > back in stock < / strong > < / span >
< span class = " pure-form-message-inline " > Only trigger re - stock notification when page changes from < strong > out of stock < / strong > to < strong > back in stock < / strong > < / span >
< / fieldset >
< / fieldset >
< fieldset class = " pure-group " >
< fieldset class = " pure-group " >
{ { render_checkbox_field ( form . follow_price_changes) } }
{ { render_checkbox_field ( form . restock_settings. follow_price_changes) } }
< span class = " pure-form-message-inline " > Changes in price should trigger a notification < / span >
< span class = " pure-form-message-inline " > Changes in price should trigger a notification < / span >
< br >
< br >
< span class = " pure-form-message-inline " > When OFF - Only care about restock detection < / span >
< span class = " pure-form-message-inline " > When OFF - Only care about restock detection < / span >
< / fieldset >
< / fieldset >
< fieldset class = " pure-group price-change-minmax " >
< fieldset class = " pure-group price-change-minmax " >
{ { render_field ( form . price_change_min, placeholder = watch [ ' restock ' ] . get ( ' price ' ) ) } }
{ { render_field ( form . restock_settings. price_change_min, placeholder = watch [ ' restock ' ] . get ( ' price ' ) ) } }
< span class = " pure-form-message-inline " > Minimum amount , only trigger a change when the price is less than this amount . < / span >
< span class = " pure-form-message-inline " > Minimum amount , only trigger a change when the price is less than this amount . < / span >
< / fieldset >
< / fieldset >
< fieldset class = " pure-group price-change-minmax " >
< fieldset class = " pure-group price-change-minmax " >
{ { render_field ( form . price_change_max, placeholder = watch [ ' restock ' ] . get ( ' price ' ) ) } }
{ { render_field ( form . restock_settings. price_change_max, placeholder = watch [ ' restock ' ] . get ( ' price ' ) ) } }
< span class = " pure-form-message-inline " > Maximum amount , only trigger a change when the price is more than this amount . < / span >
< span class = " pure-form-message-inline " > Maximum amount , only trigger a change when the price is more than this amount . < / span >
< / fieldset >
< / fieldset >
< fieldset class = " pure-group price-change-minmax " >
< fieldset class = " pure-group price-change-minmax " >
{ { render_field ( form . price_change_threshold_percent) } }
{ { render_field ( form . restock_settings. price_change_threshold_percent) } }
< span class = " pure-form-message-inline " > Price must change more than this % to trigger a change . < / span > < br >
< span class = " pure-form-message-inline " > Price must change more than this % to trigger a change . < / span > < br >
< span class = " pure-form-message-inline " > For example , If the product is $ 1 , 000 USD originally , < strong > 2 % < / strong > would mean it has to change more than $ 20 since the first check . < / span > < br >
< span class = " pure-form-message-inline " > For example , If the product is $ 1 , 000 USD originally , < strong > 2 % < / strong > would mean it has to change more than $ 20 since the first check . < / span > < br >
< / fieldset >
< / fieldset >