mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 09:15:41 +00:00
59 lines
1.7 KiB
Python
59 lines
1.7 KiB
Python
from flask_wtf import FlaskForm
|
|
from flask_wtf.file import FileField, FileRequired
|
|
from wtforms import (
|
|
BooleanField,
|
|
StringField,
|
|
SubmitField,
|
|
SelectMultipleField,
|
|
IntegerField
|
|
)
|
|
from wtforms.validators import InputRequired, Length
|
|
from app.services import SERVICES
|
|
|
|
|
|
class ContributionForm(FlaskForm):
|
|
title = StringField(
|
|
'Title',
|
|
validators=[InputRequired(), Length(max=64)]
|
|
)
|
|
description = StringField(
|
|
'Description',
|
|
validators=[InputRequired(), Length(max=255)]
|
|
)
|
|
version = StringField(
|
|
'Version',
|
|
validators=[InputRequired(), Length(max=16)]
|
|
)
|
|
compatible_service_versions = SelectMultipleField(
|
|
'Compatible service versions'
|
|
)
|
|
publisher = StringField(
|
|
'Publisher',
|
|
validators=[InputRequired(), Length(max=128)]
|
|
)
|
|
publisher_url = StringField(
|
|
'Publisher URL',
|
|
validators=[InputRequired(), Length(max=512)]
|
|
)
|
|
publishing_url = StringField(
|
|
'Publishing URL',
|
|
validators=[InputRequired(), Length(max=512)]
|
|
)
|
|
publishing_year = IntegerField(
|
|
'Publishing year',
|
|
validators=[InputRequired()]
|
|
)
|
|
shared = BooleanField('Shared', validators=[InputRequired()])
|
|
model_file = FileField('File',validators=[FileRequired()])
|
|
submit = SubmitField()
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
service_manifest = SERVICES['tesseract-ocr-pipeline']
|
|
super().__init__(*args, **kwargs)
|
|
self.compatible_service_versions.choices = [('', 'Choose your option')]
|
|
self.compatible_service_versions.choices += [
|
|
(x, x) for x in service_manifest['versions'].keys()
|
|
]
|
|
self.compatible_service_versions.default = ''
|