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