|
|
@ -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.store import ChangeDetectionStore
|
|
|
|
from changedetectionio.flask_app import login_optionally_required
|
|
|
|
from changedetectionio.flask_app import login_optionally_required
|
|
|
|
|
|
|
|
|
|
|
@ -96,15 +98,13 @@ def construct_blueprint(datastore: ChangeDetectionStore):
|
|
|
|
@tags_blueprint.route("/edit/<string:uuid>", methods=['GET'])
|
|
|
|
@tags_blueprint.route("/edit/<string:uuid>", methods=['GET'])
|
|
|
|
@login_optionally_required
|
|
|
|
@login_optionally_required
|
|
|
|
def form_tag_edit(uuid):
|
|
|
|
def form_tag_edit(uuid):
|
|
|
|
|
|
|
|
from changedetectionio.blueprint.tags.form import group_restock_settings_form
|
|
|
|
from changedetectionio.processors.restock_diff.forms import processor_settings_form
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if uuid == 'first':
|
|
|
|
if uuid == 'first':
|
|
|
|
uuid = list(datastore.data['settings']['application']['tags'].keys()).pop()
|
|
|
|
uuid = list(datastore.data['settings']['application']['tags'].keys()).pop()
|
|
|
|
|
|
|
|
|
|
|
|
default = datastore.data['settings']['application']['tags'].get(uuid)
|
|
|
|
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,
|
|
|
|
data=default,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -122,11 +122,24 @@ def construct_blueprint(datastore: ChangeDetectionStore):
|
|
|
|
import importlib.resources
|
|
|
|
import importlib.resources
|
|
|
|
templates_dir = str(importlib.resources.files("changedetectionio").joinpath('templates'))
|
|
|
|
templates_dir = str(importlib.resources.files("changedetectionio").joinpath('templates'))
|
|
|
|
env = Environment(loader=FileSystemLoader(templates_dir))
|
|
|
|
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 %}
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
|
|
|
|
toggleOpacity('#overrides_watch', '#restock-fieldset-price-group', true);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<fieldset>
|
|
|
|
|
|
|
|
<div class="pure-control-group">
|
|
|
|
|
|
|
|
<fieldset class="pure-group">
|
|
|
|
|
|
|
|
{{ render_checkbox_field(form.overrides_watch) }}
|
|
|
|
|
|
|
|
</fieldset>
|
|
|
|
|
|
|
|
</fieldset>
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
template_str += form.extra_form_content()
|
|
|
|
|
|
|
|
template = env.from_string(template_str)
|
|
|
|
included_content = template.render(**template_args)
|
|
|
|
included_content = template.render(**template_args)
|
|
|
|
|
|
|
|
|
|
|
|
output = render_template("edit-tag.html",
|
|
|
|
output = render_template("edit-tag.html",
|
|
|
|
|
|
|
|
|
|
|
|
settings_application=datastore.data['settings']['application'],
|
|
|
|
settings_application=datastore.data['settings']['application'],
|
|
|
|
extra_tab_content=form.extra_tab_content() if form.extra_tab_content() else None,
|
|
|
|
extra_tab_content=form.extra_tab_content() if form.extra_tab_content() else None,
|
|
|
|
extra_form_content=included_content,
|
|
|
|
extra_form_content=included_content,
|
|
|
@ -139,13 +152,13 @@ def construct_blueprint(datastore: ChangeDetectionStore):
|
|
|
|
@tags_blueprint.route("/edit/<string:uuid>", methods=['POST'])
|
|
|
|
@tags_blueprint.route("/edit/<string:uuid>", methods=['POST'])
|
|
|
|
@login_optionally_required
|
|
|
|
@login_optionally_required
|
|
|
|
def form_tag_edit_submit(uuid):
|
|
|
|
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':
|
|
|
|
if uuid == 'first':
|
|
|
|
uuid = list(datastore.data['settings']['application']['tags'].keys()).pop()
|
|
|
|
uuid = list(datastore.data['settings']['application']['tags'].keys()).pop()
|
|
|
|
|
|
|
|
|
|
|
|
default = datastore.data['settings']['application']['tags'].get(uuid)
|
|
|
|
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,
|
|
|
|
data=default,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
# @todo subclass form so validation works
|
|
|
|
# @todo subclass form so validation works
|
|
|
|