36
src/pbpl/forms/text.py
Normal file
36
src/pbpl/forms/text.py
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Text form"""
|
||||
|
||||
import typing as t
|
||||
|
||||
from flask_wtf import FlaskForm # type: ignore
|
||||
from wtforms import HiddenField, SubmitField, TextAreaField # type: ignore
|
||||
from wtforms.validators import DataRequired, Length # type: ignore
|
||||
|
||||
from pbpl.const import TEXT_SIZE_MAX
|
||||
|
||||
__all__: t.Tuple[str, ...] = ("TextForm",)
|
||||
|
||||
|
||||
class TextForm(FlaskForm):
|
||||
"""Example text form"""
|
||||
|
||||
text = TextAreaField(
|
||||
"Enter some text here",
|
||||
validators=(
|
||||
DataRequired(message="You must enter text"),
|
||||
Length(
|
||||
min=1,
|
||||
max=TEXT_SIZE_MAX,
|
||||
message=f"Invalid length (min=1, max={TEXT_SIZE_MAX}",
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
pow_solution = HiddenField(
|
||||
"Proof of Work Solution",
|
||||
validators=[DataRequired(message="Proof of work is required to submit.")],
|
||||
)
|
||||
|
||||
form_submit = SubmitField("Submit text")
|
||||
Reference in New Issue
Block a user