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