-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogram_form.py
24 lines (20 loc) · 939 Bytes
/
program_form.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""
Class for Program form data to be collected
"""
from constants import *
from flask_wtf import FlaskForm
from wtforms.fields.html5 import EmailField
from wtforms.fields import SubmitField, SelectField
from wtforms.validators import DataRequired, Email, InputRequired
from flask_wtf.file import FileField, FileRequired, FileAllowed
class ProgramForm(FlaskForm):
program = FileField('Program Source File:', validators=[
FileRequired('There\'s no file!'),
FileAllowed(PROGRAMS, 'Only the following file types are allowed: {}'.format(
', '.join(PROGRAMS)))
])
email = EmailField(
'Email:', validators=[DataRequired('You need to add an email!'), Email('This is not an email!')])
problem = SelectField('Problem:', choices=[(str(x), 'Problem {}'.format(x)) for x in PROBLEMS],
validators=[DataRequired('Select a problem!')])
submit = SubmitField("Run It!")