Upgrade WTforms form handler to v3 (#523)

fetcher-tidyup
Tristan Hill 3 years ago committed by GitHub
parent 615fe9290a
commit 44d599d0d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -15,7 +15,6 @@ from wtforms import (
validators, validators,
widgets, widgets,
) )
from wtforms.fields import html5
from wtforms.validators import ValidationError from wtforms.validators import ValidationError
from changedetectionio import content_fetcher from changedetectionio import content_fetcher
@ -295,9 +294,7 @@ class ValidateCSSJSONXPATHInput(object):
class quickWatchForm(Form): class quickWatchForm(Form):
# https://wtforms.readthedocs.io/en/2.3.x/fields/#module-wtforms.fields.html5 url = fields.URLField('URL', validators=[validateURL()])
# `require_tld` = False is needed even for the test harness "http://localhost:5005.." to run
url = html5.URLField('URL', validators=[validateURL()])
tag = StringField('Group tag', [validators.Optional(), validators.Length(max=35)]) tag = StringField('Group tag', [validators.Optional(), validators.Length(max=35)])
class commonSettingsForm(Form): class commonSettingsForm(Form):
@ -311,14 +308,16 @@ class commonSettingsForm(Form):
class watchForm(commonSettingsForm): class watchForm(commonSettingsForm):
url = html5.URLField('URL', validators=[validateURL()]) url = fields.URLField('URL', validators=[validateURL()])
tag = StringField('Group tag', [validators.Optional(), validators.Length(max=35)]) tag = StringField('Group tag', [validators.Optional(), validators.Length(max=35)], default='')
minutes_between_check = html5.IntegerField('Maximum time in minutes until recheck', minutes_between_check = fields.IntegerField('Maximum time in minutes until recheck',
[validators.Optional(), validators.NumberRange(min=1)]) [validators.Optional(), validators.NumberRange(min=1)])
css_filter = StringField('CSS/JSON/XPATH filter', [ValidateCSSJSONXPATHInput()])
css_filter = StringField('CSS/JSON/XPATH Filter', [ValidateCSSJSONXPATHInput()], default='')
subtractive_selectors = StringListField('Remove elements', [ValidateCSSJSONXPATHInput(allow_xpath=False, allow_json=False)]) subtractive_selectors = StringListField('Remove elements', [ValidateCSSJSONXPATHInput(allow_xpath=False, allow_json=False)])
title = StringField('Title') title = StringField('Title', default='')
ignore_text = StringListField('Ignore text', [ValidateListRegex()]) ignore_text = StringListField('Ignore text', [ValidateListRegex()])
headers = StringDictKeyValue('Request headers') headers = StringDictKeyValue('Request headers')
@ -345,7 +344,7 @@ class watchForm(commonSettingsForm):
class globalSettingsForm(commonSettingsForm): class globalSettingsForm(commonSettingsForm):
password = SaltyPasswordField() password = SaltyPasswordField()
minutes_between_check = html5.IntegerField('Maximum time in minutes until recheck', minutes_between_check = fields.IntegerField('Maximum time in minutes until recheck',
[validators.NumberRange(min=1)]) [validators.NumberRange(min=1)])
extract_title_as_title = BooleanField('Extract <title> from document and use as watch title') extract_title_as_title = BooleanField('Extract <title> from document and use as watch title')
base_url = StringField('Base URL', validators=[validators.Optional()]) base_url = StringField('Base URL', validators=[validators.Optional()])

@ -13,7 +13,7 @@ requests[socks] ~= 2.26
urllib3 > 1.26 urllib3 > 1.26
chardet > 2.3.0 chardet > 2.3.0
wtforms ~= 2.3.3 wtforms ~= 3.0
jsonpath-ng ~= 1.5.3 jsonpath-ng ~= 1.5.3
# Notification library # Notification library

Loading…
Cancel
Save