From 86388cbb9f40bf59722fce524009348aad759a22 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Thu, 28 Nov 2024 14:15:29 +0100 Subject: [PATCH] Tidy up fields, use placeholder as default so its easier to understand --- changedetectionio/flask_app.py | 3 ++- changedetectionio/forms.py | 23 ++++++++++++++++--- changedetectionio/model/Watch.py | 2 +- changedetectionio/static/js/watch-settings.js | 8 +++++-- changedetectionio/templates/_helpers.html | 2 +- 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/changedetectionio/flask_app.py b/changedetectionio/flask_app.py index 554d1cdb3b9..35270ccc1b5 100644 --- a/changedetectionio/flask_app.py +++ b/changedetectionio/flask_app.py @@ -717,7 +717,8 @@ def edit_page(uuid): form = form_class(formdata=request.form if request.method == 'POST' else None, data=default, - extra_notification_tokens=default.extra_notification_token_values() + extra_notification_tokens=default.extra_notification_token_values(), + default_system_settings=datastore.data['settings'] ) # For the form widget tag UUID back to "string name" for the field diff --git a/changedetectionio/forms.py b/changedetectionio/forms.py index 31d92aa8a36..9825236bdda 100644 --- a/changedetectionio/forms.py +++ b/changedetectionio/forms.py @@ -185,8 +185,8 @@ class ScheduleLimitForm(Form): saturday = FormField(ScheduleLimitDaySubForm, label="") sunday = FormField(ScheduleLimitDaySubForm, label="") - timezone_offset = StringField("Timezone to run in", - render_kw={"list": "timezones", "placeholder": "Default"}, + timezone = StringField("Timezone to run in", + render_kw={"list": "timezones"}, validators=[validateTimeZoneName()] ) def __init__( @@ -522,7 +522,7 @@ def __init__(self, formdata=None, obj=None, prefix="", data=None, meta=None, **k notification_title = StringField('Notification Title', default='ChangeDetection.io Notification - {{ watch_url }}', validators=[validators.Optional(), ValidateJinja2Template()]) notification_urls = StringListField('Notification URL List', validators=[validators.Optional(), ValidateAppRiseServers(), ValidateJinja2Template()]) processor = RadioField( label=u"Processor - What do you want to achieve?", choices=processors.available_processors(), default="text_json_diff") - timezone = StringField("Timezone to run in", render_kw={"list": "timezones", "placeholder": "Default"}, validators=[validateTimeZoneName()]) + timezone = StringField("Timezone to run in", render_kw={"list": "timezones"}, validators=[validateTimeZoneName()]) webdriver_delay = IntegerField('Wait seconds before extracting text', validators=[validators.Optional(), validators.NumberRange(min=1, message="Should contain one or more seconds")]) @@ -655,6 +655,23 @@ def validate(self, **kwargs): return result + def __init__( + self, + formdata=None, + obj=None, + prefix="", + data=None, + meta=None, + **kwargs, + ): + super().__init__(formdata, obj, prefix, data, meta, **kwargs) + + default_tz = kwargs.get('default_system_settings').get('application', {}).get('timezone') + if default_tz: + self.time_schedule_limit.form.timezone.render_kw['placeholder'] = default_tz + + + class SingleExtraProxy(Form): # maybe better to set some