distribusi-verse: medium-tech web app content management system for the web
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.

94 lines
2.6 KiB

from flask_wtf import FlaskForm
from flask_wtf.file import FileField, FileAllowed, FileRequired, FileSize
from wtforms import validators
3 years ago
from wtforms.validators import (
Length,
NumberRange,
DataRequired,
ValidationError,
)
from wtforms import (
SubmitField,
StringField,
IntegerField,
SelectField,
)
class UploadForm(FlaskForm):
"""File upload class for a new site in distribusi-verse"""
7 months ago
def _distribusiname(form, field):
3 years ago
if field.data.lower() == "new":
raise ValidationError("Name has to be unique and not just new.")
sitename = StringField(
7 months ago
"Name of your archive section:",
validators=[validators.InputRequired(), Length(2, 100), _distribusiname],
)
academicyear = SelectField(
7 months ago
"Year",
validate_choice=True,
coerce=str,
choices=[
7 months ago
(u'2017', u'2017'),
(u'2018', u'2018'),
(u'2019', u'2019'),
(u'2020', u'2020'),
(u'2021', u'2021'),
(u'2022', u'2022'),
(u'2023', u'2023'),
(u'2024', u'2024'),
(u'2025', u'2025'),
],
option_widget=None,
validators=[DataRequired()]
)
term = SelectField(
7 months ago
"Category:",
validate_choice=True,
coerce=str,
choices=[
7 months ago
(u'event', u'event'),
(u'gathering', u'gathering'),
(u'work session', u'work session'),
(u'workgroup', u'workgroup'),
(u'performance', u'performance'),
(u'music event', u'music event'),
],
option_widget=None,
validators=[DataRequired()]
)
tags = StringField(
"Add tags, seperated by commas. No need for the '#' sign:",
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")