mirror of
https://github.com/dgtlmoon/changedetection.io.git
synced 2026-05-04 00:30:53 +00:00
8cfa6eb336
Build and push containers / metadata (push) Has been cancelled
Build and push containers / build-push-containers (push) Has been cancelled
Publish Python 🐍distribution 📦 to PyPI and TestPyPI / Build distribution 📦 (push) Has been cancelled
Publish Python 🐍distribution 📦 to PyPI and TestPyPI / Test the built package works basically. (push) Has been cancelled
Publish Python 🐍distribution 📦 to PyPI and TestPyPI / Publish Python 🐍 distribution 📦 to PyPI (push) Has been cancelled
ChangeDetection.io App Test / lint-code (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-10 (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-11 (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-12 (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-13 (push) Has been cancelled
ChangeDetection.io App Test / test-application-3-14 (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
45 lines
1.7 KiB
Python
45 lines
1.7 KiB
Python
# Condition Rule Form (for each rule row)
|
|
from wtforms import Form, SelectField, StringField, validators
|
|
from wtforms import validators
|
|
from flask_babel import lazy_gettext as _l
|
|
|
|
class ConditionFormRow(Form):
|
|
|
|
# ✅ Ensure Plugins Are Loaded BEFORE Importing Choices
|
|
from changedetectionio.conditions import plugin_manager
|
|
from changedetectionio.conditions import operator_choices, field_choices
|
|
field = SelectField(
|
|
_l("Field"),
|
|
choices=field_choices,
|
|
validators=[validators.Optional()]
|
|
)
|
|
|
|
operator = SelectField(
|
|
_l("Operator"),
|
|
choices=operator_choices,
|
|
validators=[validators.Optional()]
|
|
)
|
|
|
|
value = StringField(_l("Value"), validators=[validators.Optional()], render_kw={"placeholder": _l("A value")})
|
|
|
|
def validate(self, extra_validators=None):
|
|
# First, run the default validators
|
|
if not super().validate(extra_validators):
|
|
return False
|
|
|
|
# Custom validation logic
|
|
# If any of the operator/field/value is set, then they must be all set
|
|
if any(value not in ("", False, "None", None) for value in [self.operator.data, self.field.data, self.value.data]):
|
|
if not self.operator.data or self.operator.data == 'None':
|
|
self.operator.errors.append(_l("Operator is required."))
|
|
return False
|
|
|
|
if not self.field.data or self.field.data == 'None':
|
|
self.field.errors.append(_l("Field is required."))
|
|
return False
|
|
|
|
if not self.value.data:
|
|
self.value.errors.append(_l("Value is required."))
|
|
return False
|
|
|
|
return True # Only return True if all conditions pass |