You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.9 KiB
69 lines
1.9 KiB
from flask_wtf import FlaskForm
|
|
from flask_wtf.file import FileField, FileAllowed, FileRequired, FileSize
|
|
from wtforms import validators
|
|
from wtforms.validators import Length, NumberRange, DataRequired
|
|
from wtforms import (
|
|
SubmitField,
|
|
StringField,
|
|
IntegerField,
|
|
SelectField,
|
|
)
|
|
|
|
|
|
class UploadForm(FlaskForm):
|
|
"""File upload class for a new site in distribusi-verse"""
|
|
|
|
sitename = StringField(
|
|
"Name of your website:",
|
|
validators=[validators.InputRequired(), Length(2, 100)],
|
|
)
|
|
academicyear = StringField(
|
|
"Academic year:",
|
|
validators=[validators.InputRequired(), Length(9, 10)],
|
|
)
|
|
term = SelectField(
|
|
"Term:",
|
|
validate_choice=True,
|
|
coerce=str,
|
|
choices=[
|
|
(u'1.2', u'1.2'),
|
|
(u'2.3', u'2.3'),
|
|
(u'3.1', u'3.1'),
|
|
(u'4.1', u'4.1'),
|
|
(u'4.2', u'4.2'),
|
|
],
|
|
option_widget=None,
|
|
validators=[DataRequired()]
|
|
)
|
|
tags = StringField(
|
|
"Add search tags, comma-separated:",
|
|
validators=[validators.InputRequired(), Length(2, 500)],
|
|
)
|
|
|
|
course = SelectField(
|
|
u'Course:',
|
|
validate_choice=True,
|
|
coerce=str,
|
|
choices=[
|
|
('hacking', u'Autonomous - Hacking'),
|
|
('digitalcraft', u'Autonomous - Digital Craft'),
|
|
('criticalstudies', u'Autonomous - Critical Studies'),
|
|
('publicprivate', u'Autonomous - Public&Private'),
|
|
],
|
|
option_widget=None,
|
|
validators=[DataRequired()]
|
|
)
|
|
|
|
zipfile = FileField(
|
|
"Upload your zip file with content here:",
|
|
validators=[
|
|
FileAllowed(["zip"], "Zip archives only!"),
|
|
FileRequired(),
|
|
FileSize(
|
|
max_size=104857600,
|
|
message="Zipfile size must be smaller than 100MB",
|
|
),
|
|
],
|
|
)
|
|
|
|
submit = SubmitField("Upload")
|
|
|