create dictionary of base user form fields
This commit is contained in:
parent
65bc05d214
commit
dab5fe83fc
@ -9,41 +9,33 @@ from .data import SERVICE_BRANCHES
|
||||
|
||||
from .validators import Alphabet, DateRange, PhoneNumber
|
||||
|
||||
|
||||
class EditUserForm(ValidatedForm):
|
||||
|
||||
first_name = StringField("First Name", validators=[Required(), Alphabet()])
|
||||
|
||||
last_name = StringField("Last Name", validators=[Required(), Alphabet()])
|
||||
|
||||
email = EmailField(
|
||||
USER_FIELDS = {
|
||||
"first_name": StringField("First Name", validators=[Required(), Alphabet()]),
|
||||
"last_name": StringField("Last Name", validators=[Required(), Alphabet()]),
|
||||
"email": EmailField(
|
||||
"E-mail Address",
|
||||
description="Enter your preferred contact e-mail address",
|
||||
validators=[Required(), Email()],
|
||||
)
|
||||
|
||||
phone_number = TelField(
|
||||
),
|
||||
"phone_number": TelField(
|
||||
"Phone Number",
|
||||
description="Enter your 10-digit U.S. phone number",
|
||||
validators=[PhoneNumber()],
|
||||
)
|
||||
|
||||
service_branch = SelectField(
|
||||
),
|
||||
"service_branch": SelectField(
|
||||
"Service Branch or Agency",
|
||||
description="Which service or organization do you belong to within the DoD?",
|
||||
choices=SERVICE_BRANCHES,
|
||||
)
|
||||
|
||||
citizenship = RadioField(
|
||||
),
|
||||
"citizenship": RadioField(
|
||||
description="What is your citizenship status?",
|
||||
choices=[
|
||||
("United States", "United States"),
|
||||
("Foreign National", "Foreign National"),
|
||||
("Other", "Other"),
|
||||
],
|
||||
)
|
||||
|
||||
designation = RadioField(
|
||||
),
|
||||
"designation": RadioField(
|
||||
"Designation of Person",
|
||||
description="What is your designation within the DoD?",
|
||||
choices=[
|
||||
@ -51,9 +43,8 @@ class EditUserForm(ValidatedForm):
|
||||
("civilian", "Civilian"),
|
||||
("contractor", "Contractor"),
|
||||
],
|
||||
)
|
||||
|
||||
date_latest_training = DateField(
|
||||
),
|
||||
"date_latest_training": DateField(
|
||||
"Latest Information Assurance (IA) Training Completion Date",
|
||||
description='To complete the training, you can find it in <a class="icon-link" href="https://iatraining.disa.mil/eta/disa_cac2018/launchPage.htm" target="_blank">Information Assurance Cyber Awareness Challange</a> website.',
|
||||
validators=[
|
||||
@ -64,4 +55,16 @@ class EditUserForm(ValidatedForm):
|
||||
)
|
||||
],
|
||||
format="%m/%d/%Y",
|
||||
)
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
class EditUserForm(ValidatedForm):
|
||||
first_name = USER_FIELDS["first_name"]
|
||||
last_name = USER_FIELDS["last_name"]
|
||||
email = USER_FIELDS["email"]
|
||||
phone_number = USER_FIELDS["phone_number"]
|
||||
service_branch = USER_FIELDS["service_branch"]
|
||||
citizenship = USER_FIELDS["citizenship"]
|
||||
designation = USER_FIELDS["designation"]
|
||||
date_latest_training = USER_FIELDS["date_latest_training"]
|
||||
|
@ -5,6 +5,7 @@ from wtforms.validators import Email, Length, Optional, InputRequired, DataRequi
|
||||
|
||||
from .fields import SelectField
|
||||
from .forms import ValidatedForm
|
||||
from .edit_user import USER_FIELDS
|
||||
from .data import (
|
||||
SERVICE_BRANCHES,
|
||||
ASSISTANCE_ORG_TYPES,
|
||||
@ -161,58 +162,35 @@ class DetailsOfUseForm(ValidatedForm):
|
||||
)
|
||||
|
||||
|
||||
class InformationAboutYouForm(ValidatedForm):
|
||||
fname_request = StringField("First Name", validators=[InputRequired(), Alphabet()])
|
||||
def inherit_field(unbound_field, append_validators=[]):
|
||||
if "validators" in unbound_field.kwargs:
|
||||
unbound_field.kwargs["validators"] += append_validators
|
||||
return unbound_field.field_class(*unbound_field.args, **unbound_field.kwargs)
|
||||
|
||||
lname_request = StringField("Last Name", validators=[InputRequired(), Alphabet()])
|
||||
|
||||
class InformationAboutYouForm(ValidatedForm):
|
||||
fname_request = USER_FIELDS["first_name"]
|
||||
|
||||
lname_request = USER_FIELDS["last_name"]
|
||||
|
||||
email_request = EmailField("E-mail Address", validators=[InputRequired(), Email()])
|
||||
|
||||
phone_number = TelField(
|
||||
"Phone Number",
|
||||
description="Enter a 10-digit phone number",
|
||||
validators=[InputRequired(), PhoneNumber()],
|
||||
phone_number = inherit_field(
|
||||
USER_FIELDS["phone_number"], append_validators=[InputRequired()]
|
||||
)
|
||||
|
||||
service_branch = SelectField(
|
||||
"Service Branch or Agency",
|
||||
description="Which service or organization do you belong to within the DoD?",
|
||||
choices=SERVICE_BRANCHES,
|
||||
service_branch = USER_FIELDS["service_branch"]
|
||||
|
||||
citizenship = inherit_field(
|
||||
USER_FIELDS["citizenship"], append_validators=[InputRequired()]
|
||||
)
|
||||
|
||||
citizenship = RadioField(
|
||||
description="What is your citizenship status?",
|
||||
choices=[
|
||||
("United States", "United States"),
|
||||
("Foreign National", "Foreign National"),
|
||||
("Other", "Other"),
|
||||
],
|
||||
validators=[InputRequired()],
|
||||
designation = inherit_field(
|
||||
USER_FIELDS["designation"], append_validators=[InputRequired()]
|
||||
)
|
||||
|
||||
designation = RadioField(
|
||||
"Designation of Person",
|
||||
description="What is your designation within the DoD?",
|
||||
choices=[
|
||||
("military", "Military"),
|
||||
("civilian", "Civilian"),
|
||||
("contractor", "Contractor"),
|
||||
],
|
||||
validators=[InputRequired()],
|
||||
)
|
||||
|
||||
date_latest_training = DateField(
|
||||
"Latest Information Assurance (IA) Training Completion Date",
|
||||
description='To complete the training, you can find it in <a class="icon-link" href="https://iatraining.disa.mil/eta/disa_cac2018/launchPage.htm" target="_blank">Information Assurance Cyber Awareness Challange</a> website.',
|
||||
validators=[
|
||||
InputRequired(),
|
||||
DateRange(
|
||||
lower_bound=pendulum.duration(years=1),
|
||||
upper_bound=pendulum.duration(days=0),
|
||||
message="Must be a date within the last year.",
|
||||
),
|
||||
],
|
||||
format="%m/%d/%Y",
|
||||
date_latest_training = inherit_field(
|
||||
USER_FIELDS["date_latest_training"], append_validators=[InputRequired()]
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user