Source code for election_day.forms.upload.rest
from onegov.election_day import _
from onegov.election_day.forms.upload.common import ALLOWED_MIME_TYPES
from onegov.election_day.forms.upload.common import ALLOWED_MIME_TYPES_XML
from onegov.form import Form
from onegov.form.fields import UploadField
from onegov.form.validators import FileSizeLimit
from onegov.form.validators import InputRequiredIf
from onegov.form.validators import WhitelistedMimeType
from wtforms.fields import RadioField
from wtforms.fields import StringField
from wtforms.validators import DataRequired
from wtforms.validators import InputRequired
[docs]
class UploadRestForm(Form):
[docs]
type = RadioField(
_('Type'),
choices=[
('vote', _('Vote')),
('election', _('Election')),
('parties', _('Party results')),
('xml', 'eCH-0252'),
],
validators=[
InputRequired()
],
default='vote'
)
[docs]
results = UploadField(
label=_('Results'),
validators=[
DataRequired(),
WhitelistedMimeType(ALLOWED_MIME_TYPES | ALLOWED_MIME_TYPES_XML),
FileSizeLimit(50 * 1024 * 1024)
],
render_kw={'force_simple': True}
)