|
|
@ -5,20 +5,30 @@ from wtforms import (IntegerField, SelectField, StringField, SubmitField, |
|
|
|
from wtforms.validators import (DataRequired, Length, NumberRange, |
|
|
|
ValidationError) |
|
|
|
|
|
|
|
from app import settings |
|
|
|
|
|
|
|
|
|
|
|
class UploadForm(FlaskForm): |
|
|
|
"""File upload class for a new site in distribusi-verse""" |
|
|
|
|
|
|
|
def _distribusiname(form, field): |
|
|
|
def distribusiname(form, field): |
|
|
|
if field.data.lower() == "new": |
|
|
|
raise ValidationError("Name has to be unique and not just new.") |
|
|
|
|
|
|
|
def category_choices(): |
|
|
|
APP = settings() |
|
|
|
config_categories = APP.config["categories"] |
|
|
|
categories = [] |
|
|
|
for config_category in config_categories: |
|
|
|
categories.append((config_category, config_category)) |
|
|
|
return categories |
|
|
|
|
|
|
|
sitename = StringField( |
|
|
|
"Name of your archive section:", |
|
|
|
validators=[ |
|
|
|
validators.InputRequired(), |
|
|
|
Length(2, 100), |
|
|
|
_distribusiname, |
|
|
|
distribusiname, |
|
|
|
], |
|
|
|
) |
|
|
|
year = SelectField( |
|
|
@ -43,14 +53,7 @@ class UploadForm(FlaskForm): |
|
|
|
"Category:", |
|
|
|
validate_choice=True, |
|
|
|
coerce=str, |
|
|
|
choices=[ |
|
|
|
("event", "event"), |
|
|
|
("gathering", "gathering"), |
|
|
|
("work session", "work session"), |
|
|
|
("workgroup", "workgroup"), |
|
|
|
("performance", "performance"), |
|
|
|
("music event", "music event"), |
|
|
|
], |
|
|
|
choices=category_choices, |
|
|
|
option_widget=None, |
|
|
|
validators=[DataRequired()], |
|
|
|
) |
|
|
|