mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
Remove helper comments and add service versions dynamically to select.
This commit is contained in:
parent
40a71ad9dd
commit
36d3ea2ce0
@ -2,81 +2,57 @@ from flask_wtf import FlaskForm
|
|||||||
from flask_wtf.file import FileField, FileRequired
|
from flask_wtf.file import FileField, FileRequired
|
||||||
from wtforms import (
|
from wtforms import (
|
||||||
BooleanField,
|
BooleanField,
|
||||||
PasswordField,
|
|
||||||
StringField,
|
StringField,
|
||||||
SubmitField,
|
SubmitField,
|
||||||
SelectMultipleField,
|
SelectMultipleField,
|
||||||
ValidationError, FieldList, IntegerField
|
IntegerField
|
||||||
)
|
)
|
||||||
from wtforms.validators import InputRequired, Email, EqualTo, Length, Regexp
|
from wtforms.validators import InputRequired, Length
|
||||||
from app.models import User
|
from app.services import SERVICES
|
||||||
|
|
||||||
|
|
||||||
class ContributionForm(FlaskForm):
|
class ContributionForm(FlaskForm):
|
||||||
|
|
||||||
# The id field will be generated on insert.
|
|
||||||
# The user_id will be retrieved from the user who is performing this operation.
|
|
||||||
|
|
||||||
# title = db.Column(db.String(64))
|
|
||||||
title = StringField(
|
title = StringField(
|
||||||
'Title',
|
'Title',
|
||||||
validators=[InputRequired(), Length(max=64)]
|
validators=[InputRequired(), Length(max=64)]
|
||||||
)
|
)
|
||||||
|
|
||||||
# description = db.Column(db.String(255))
|
|
||||||
description = StringField(
|
description = StringField(
|
||||||
'Description',
|
'Description',
|
||||||
validators=[InputRequired(), Length(max=255)]
|
validators=[InputRequired(), Length(max=255)]
|
||||||
)
|
)
|
||||||
|
|
||||||
# version = db.Column(db.String(16))
|
|
||||||
version = StringField(
|
version = StringField(
|
||||||
'Version',
|
'Version',
|
||||||
validators=[InputRequired(), Length(max=16)]
|
validators=[InputRequired(), Length(max=16)]
|
||||||
)
|
)
|
||||||
|
|
||||||
# compatible_service_versions = db.Column(ContainerColumn(list, 255))
|
|
||||||
compatible_service_versions = SelectMultipleField(
|
compatible_service_versions = SelectMultipleField(
|
||||||
'Compatible Service Versions',
|
'Compatible service versions'
|
||||||
choices=["asd", "blub", "bla"]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# publisher = db.Column(db.String(128))
|
|
||||||
publisher = StringField(
|
publisher = StringField(
|
||||||
'Publisher',
|
'Publisher',
|
||||||
validators=[InputRequired(), Length(max=128)]
|
validators=[InputRequired(), Length(max=128)]
|
||||||
)
|
)
|
||||||
|
|
||||||
# publisher_url = db.Column(db.String(512))
|
|
||||||
publisher_url = StringField(
|
publisher_url = StringField(
|
||||||
'Publisher URL',
|
'Publisher URL',
|
||||||
validators=[InputRequired(), Length(max=512)]
|
validators=[InputRequired(), Length(max=512)]
|
||||||
)
|
)
|
||||||
|
|
||||||
# publishing_url = db.Column(db.String(512))
|
|
||||||
publishing_url = StringField(
|
publishing_url = StringField(
|
||||||
'Publishing URL',
|
'Publishing URL',
|
||||||
validators=[InputRequired(), Length(max=512)]
|
validators=[InputRequired(), Length(max=512)]
|
||||||
)
|
)
|
||||||
|
|
||||||
# publishing_year = db.Column(db.Integer)
|
|
||||||
publishing_year = IntegerField(
|
publishing_year = IntegerField(
|
||||||
'Publishing year',
|
'Publishing year',
|
||||||
validators=[InputRequired()]
|
validators=[InputRequired()]
|
||||||
)
|
)
|
||||||
|
shared = BooleanField('Shared', validators=[InputRequired()])
|
||||||
# shared = db.Column(db.Boolean, default=False)
|
model_file = FileField('File',validators=[FileRequired()])
|
||||||
shared = BooleanField(
|
|
||||||
'Shared',
|
|
||||||
validators=[InputRequired()]
|
|
||||||
)
|
|
||||||
|
|
||||||
# file upload
|
|
||||||
file = FileField(
|
|
||||||
'File',
|
|
||||||
validators=[FileRequired()]
|
|
||||||
)
|
|
||||||
|
|
||||||
submit = SubmitField()
|
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 = ''
|
||||||
|
Loading…
Reference in New Issue
Block a user