nopaque/app/corpora/forms.py

34 lines
1.0 KiB
Python
Raw Normal View History

2023-03-31 07:14:21 +00:00
from flask_wtf import FlaskForm
2023-03-10 09:33:11 +00:00
from wtforms import StringField, SubmitField, TextAreaField
2022-09-02 11:07:30 +00:00
from wtforms.validators import InputRequired, Length
2023-03-31 07:14:21 +00:00
class CorpusBaseForm(FlaskForm):
2022-11-29 14:28:10 +00:00
description = TextAreaField(
2022-09-02 11:07:30 +00:00
'Description',
validators=[InputRequired(), Length(max=255)]
)
title = StringField('Title', validators=[InputRequired(), Length(max=32)])
submit = SubmitField()
2022-11-29 14:28:10 +00:00
class CreateCorpusForm(CorpusBaseForm):
2023-03-31 07:14:21 +00:00
def __init__(self, *args, **kwargs):
if 'prefix' not in kwargs:
kwargs['prefix'] = 'create-corpus-form'
super().__init__(*args, **kwargs)
2022-11-29 14:28:10 +00:00
class UpdateCorpusForm(CorpusBaseForm):
2023-03-31 07:14:21 +00:00
def __init__(self, *args, **kwargs):
if 'prefix' not in kwargs:
kwargs['prefix'] = 'update-corpus-form'
super().__init__(*args, **kwargs)
2022-11-29 14:28:10 +00:00
2023-03-31 07:14:21 +00:00
class ImportCorpusForm(FlaskForm):
def __init__(self, *args, **kwargs):
if 'prefix' not in kwargs:
kwargs['prefix'] = 'import-corpus-form'
super().__init__(*args, **kwargs)