aboutsummaryrefslogtreecommitdiff
path: root/webmentions_ssg/forms.py
diff options
context:
space:
mode:
Diffstat (limited to 'webmentions_ssg/forms.py')
-rw-r--r--webmentions_ssg/forms.py32
1 files changed, 10 insertions, 22 deletions
diff --git a/webmentions_ssg/forms.py b/webmentions_ssg/forms.py
index a721dc6..d557907 100644
--- a/webmentions_ssg/forms.py
+++ b/webmentions_ssg/forms.py
@@ -73,16 +73,14 @@ class HTTPXURL:
class NotEqualTo:
- """
- Validate that a field does not equal another field.
+ """Validate that a field does not equal another field.
:param fieldname: Name of the field to compare against.
:param message: Optional validation error message.
"""
def __init__(self, fieldname: str, message: str | None = None) -> None:
- """
- Initialize the validator.
+ """Initialize the validator.
:param fieldname: Name of the field to compare against.
:param message: Optional validation error message.
@@ -91,8 +89,7 @@ class NotEqualTo:
self.message = message
def __call__(self, form: BaseForm, field: Field) -> None:
- """
- Validate that two fields do not contain equal values.
+ """Validate that two fields do not contain equal values.
:param form: Form containing the fields to compare.
:param field: Field being validated.
@@ -110,8 +107,7 @@ class NotEqualTo:
return
d = {
- "other_label": hasattr(other, "label")
- and other.label.text
+ "other_label": (hasattr(other, "label") and other.label.text)
or self.fieldname,
"other_name": self.fieldname,
}
@@ -122,23 +118,20 @@ class NotEqualTo:
class AllowedHostname:
- """
- Validate that a URL uses an allowed hostname.
+ """Validate that a URL uses an allowed hostname.
:param message: Optional validation error message.
"""
def __init__(self, message: str | None = None) -> None:
- """
- Initialize the validator.
+ """Initialize the validator.
:param message: Optional validation error message.
"""
self.message = message
def __call__(self, form: BaseForm, field: Field) -> None:
- """
- Validate that a URL uses an allowed hostname.
+ """Validate that a URL uses an allowed hostname.
:param form: Form containing the field.
:param field: Field containing the URL to validate.
@@ -175,9 +168,7 @@ class PublicIPLiteral:
class LoginForm(FlaskForm):
- """
- Form for authenticating a user.
- """
+ """Form for authenticating a user."""
username = StringField("Username", validators=[InputRequired()])
password = PasswordField("Password", validators=[InputRequired()])
@@ -185,8 +176,7 @@ class LoginForm(FlaskForm):
class EndpointForm(FlaskForm):
- """
- Form for receiving a Webmention.
+ """Form for receiving a Webmention.
The source must be a public HTTP or HTTPS URL distinct from the target.
The target must be an HTTP or HTTPS URL using an allowed hostname.
@@ -226,8 +216,6 @@ class EndpointForm(FlaskForm):
class AdminActionForm(FlaskForm):
- """
- Form for confirming an administrative action.
- """
+ """Form for confirming an administrative action."""
submit = SubmitField("Confirm")