diff --git a/changedetectionio/blueprint/tags/__init__.py b/changedetectionio/blueprint/tags/__init__.py index 65117bf2..2c18d192 100644 --- a/changedetectionio/blueprint/tags/__init__.py +++ b/changedetectionio/blueprint/tags/__init__.py @@ -1,4 +1,6 @@ -from flask import Blueprint, request, make_response, render_template, flash, url_for, redirect +from flask import Blueprint, request, render_template, flash, url_for, redirect + + from changedetectionio.store import ChangeDetectionStore from changedetectionio.flask_app import login_optionally_required @@ -96,15 +98,13 @@ def construct_blueprint(datastore: ChangeDetectionStore): @tags_blueprint.route("/edit/", methods=['GET']) @login_optionally_required def form_tag_edit(uuid): - - from changedetectionio.processors.restock_diff.forms import processor_settings_form - + from changedetectionio.blueprint.tags.form import group_restock_settings_form if uuid == 'first': uuid = list(datastore.data['settings']['application']['tags'].keys()).pop() default = datastore.data['settings']['application']['tags'].get(uuid) - form = processor_settings_form(formdata=request.form if request.method == 'POST' else None, + form = group_restock_settings_form(formdata=request.form if request.method == 'POST' else None, data=default, ) @@ -122,11 +122,24 @@ def construct_blueprint(datastore: ChangeDetectionStore): import importlib.resources templates_dir = str(importlib.resources.files("changedetectionio").joinpath('templates')) env = Environment(loader=FileSystemLoader(templates_dir)) - template = env.from_string(form.extra_form_content()) + template_str = """{% from '_helpers.html' import render_field, render_checkbox_field, render_button %} + +
+
+
+ {{ render_checkbox_field(form.overrides_watch) }} +
+
+ """ + template_str += form.extra_form_content() + template = env.from_string(template_str) included_content = template.render(**template_args) output = render_template("edit-tag.html", - settings_application=datastore.data['settings']['application'], extra_tab_content=form.extra_tab_content() if form.extra_tab_content() else None, extra_form_content=included_content, @@ -139,13 +152,13 @@ def construct_blueprint(datastore: ChangeDetectionStore): @tags_blueprint.route("/edit/", methods=['POST']) @login_optionally_required def form_tag_edit_submit(uuid): - from changedetectionio.processors.restock_diff.forms import processor_settings_form + from changedetectionio.blueprint.tags.form import group_restock_settings_form if uuid == 'first': uuid = list(datastore.data['settings']['application']['tags'].keys()).pop() default = datastore.data['settings']['application']['tags'].get(uuid) - form = processor_settings_form(formdata=request.form if request.method == 'POST' else None, + form = group_restock_settings_form(formdata=request.form if request.method == 'POST' else None, data=default, ) # @todo subclass form so validation works diff --git a/changedetectionio/blueprint/tags/form.py b/changedetectionio/blueprint/tags/form.py index 22e8b077..6ff3a503 100644 --- a/changedetectionio/blueprint/tags/form.py +++ b/changedetectionio/blueprint/tags/form.py @@ -1,16 +1,15 @@ from wtforms import ( - BooleanField, Form, - IntegerField, - RadioField, - SelectField, StringField, SubmitField, - TextAreaField, validators, ) +from wtforms.fields.simple import BooleanField +from changedetectionio.processors.restock_diff.forms import processor_settings_form as restock_settings_form +class group_restock_settings_form(restock_settings_form): + overrides_watch = BooleanField('Activate for individual watches in this tag/group?', default=False) class SingleTag(Form): diff --git a/changedetectionio/model/Tag.py b/changedetectionio/model/Tag.py index 60e27a48..6dca480c 100644 --- a/changedetectionio/model/Tag.py +++ b/changedetectionio/model/Tag.py @@ -1,14 +1,14 @@ from changedetectionio.model import watch_base + class model(watch_base): def __init__(self, *arg, **kw): - super(model, self).__init__(*arg, **kw) + self['overrides_watch'] = kw.get('default', {}).get('overrides_watch') + if kw.get('default'): self.update(kw['default']) del kw['default'] - - diff --git a/changedetectionio/processors/restock_diff/forms.py b/changedetectionio/processors/restock_diff/forms.py index bfebed61..92e5d31c 100644 --- a/changedetectionio/processors/restock_diff/forms.py +++ b/changedetectionio/processors/restock_diff/forms.py @@ -34,7 +34,7 @@ class processor_settings_form(processor_text_json_diff_form): -
+
{{ render_checkbox_field(form.in_stock_only) }} diff --git a/changedetectionio/static/js/watch-settings.js b/changedetectionio/static/js/watch-settings.js index 6d45dc76..a55d2813 100644 --- a/changedetectionio/static/js/watch-settings.js +++ b/changedetectionio/static/js/watch-settings.js @@ -27,6 +27,5 @@ $(document).ready(function () { toggleOpacity('#time_between_check_use_default', '#time_between_check', false); - });