bump project
This commit is contained in:
24
app/people/forms.py
Normal file
24
app/people/forms.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import FileField, StringField, SubmitField, TextAreaField
|
||||
from wtforms.validators import DataRequired, Length, ValidationError
|
||||
|
||||
from app.models import Person
|
||||
|
||||
|
||||
class PersonForm(FlaskForm):
|
||||
full_name = StringField("Full name", validators=[DataRequired(), Length(max=160)])
|
||||
employee_id = StringField("Employee ID", validators=[DataRequired(), Length(max=80)])
|
||||
notes = TextAreaField("Notes", validators=[Length(max=2000)])
|
||||
photo_1 = FileField("Reference photo 1")
|
||||
photo_2 = FileField("Reference photo 2")
|
||||
photo_3 = FileField("Reference photo 3")
|
||||
photo_4 = FileField("Reference photo 4")
|
||||
submit = SubmitField("Enroll person")
|
||||
|
||||
def validate_employee_id(self, field) -> None:
|
||||
employee_id = field.data.strip()
|
||||
if Person.query.filter_by(employee_id=employee_id).first():
|
||||
raise ValidationError("That employee ID is already enrolled.")
|
||||
field.data = employee_id
|
||||
Reference in New Issue
Block a user