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
|
from .validators import Alphabet, DateRange, PhoneNumber
|
||||||
|
|
||||||
|
USER_FIELDS = {
|
||||||
class EditUserForm(ValidatedForm):
|
"first_name": StringField("First Name", validators=[Required(), Alphabet()]),
|
||||||
|
"last_name": StringField("Last Name", validators=[Required(), Alphabet()]),
|
||||||
first_name = StringField("First Name", validators=[Required(), Alphabet()])
|
"email": EmailField(
|
||||||
|
|
||||||
last_name = StringField("Last Name", validators=[Required(), Alphabet()])
|
|
||||||
|
|
||||||
email = EmailField(
|
|
||||||
"E-mail Address",
|
"E-mail Address",
|
||||||
description="Enter your preferred contact e-mail address",
|
description="Enter your preferred contact e-mail address",
|
||||||
validators=[Required(), Email()],
|
validators=[Required(), Email()],
|
||||||
)
|
),
|
||||||
|
"phone_number": TelField(
|
||||||
phone_number = TelField(
|
|
||||||
"Phone Number",
|
"Phone Number",
|
||||||
description="Enter your 10-digit U.S. phone number",
|
description="Enter your 10-digit U.S. phone number",
|
||||||
validators=[PhoneNumber()],
|
validators=[PhoneNumber()],
|
||||||
)
|
),
|
||||||
|
"service_branch": SelectField(
|
||||||
service_branch = SelectField(
|
|
||||||
"Service Branch or Agency",
|
"Service Branch or Agency",
|
||||||
description="Which service or organization do you belong to within the DoD?",
|
description="Which service or organization do you belong to within the DoD?",
|
||||||
choices=SERVICE_BRANCHES,
|
choices=SERVICE_BRANCHES,
|
||||||
)
|
),
|
||||||
|
"citizenship": RadioField(
|
||||||
citizenship = RadioField(
|
|
||||||
description="What is your citizenship status?",
|
description="What is your citizenship status?",
|
||||||
choices=[
|
choices=[
|
||||||
("United States", "United States"),
|
("United States", "United States"),
|
||||||
("Foreign National", "Foreign National"),
|
("Foreign National", "Foreign National"),
|
||||||
("Other", "Other"),
|
("Other", "Other"),
|
||||||
],
|
],
|
||||||
)
|
),
|
||||||
|
"designation": RadioField(
|
||||||
designation = RadioField(
|
|
||||||
"Designation of Person",
|
"Designation of Person",
|
||||||
description="What is your designation within the DoD?",
|
description="What is your designation within the DoD?",
|
||||||
choices=[
|
choices=[
|
||||||
@ -51,9 +43,8 @@ class EditUserForm(ValidatedForm):
|
|||||||
("civilian", "Civilian"),
|
("civilian", "Civilian"),
|
||||||
("contractor", "Contractor"),
|
("contractor", "Contractor"),
|
||||||
],
|
],
|
||||||
)
|
),
|
||||||
|
"date_latest_training": DateField(
|
||||||
date_latest_training = DateField(
|
|
||||||
"Latest Information Assurance (IA) Training Completion Date",
|
"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.',
|
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=[
|
validators=[
|
||||||
@ -64,4 +55,16 @@ class EditUserForm(ValidatedForm):
|
|||||||
)
|
)
|
||||||
],
|
],
|
||||||
format="%m/%d/%Y",
|
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 .fields import SelectField
|
||||||
from .forms import ValidatedForm
|
from .forms import ValidatedForm
|
||||||
|
from .edit_user import USER_FIELDS
|
||||||
from .data import (
|
from .data import (
|
||||||
SERVICE_BRANCHES,
|
SERVICE_BRANCHES,
|
||||||
ASSISTANCE_ORG_TYPES,
|
ASSISTANCE_ORG_TYPES,
|
||||||
@ -161,58 +162,35 @@ class DetailsOfUseForm(ValidatedForm):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class InformationAboutYouForm(ValidatedForm):
|
def inherit_field(unbound_field, append_validators=[]):
|
||||||
fname_request = StringField("First Name", validators=[InputRequired(), Alphabet()])
|
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()])
|
email_request = EmailField("E-mail Address", validators=[InputRequired(), Email()])
|
||||||
|
|
||||||
phone_number = TelField(
|
phone_number = inherit_field(
|
||||||
"Phone Number",
|
USER_FIELDS["phone_number"], append_validators=[InputRequired()]
|
||||||
description="Enter a 10-digit phone number",
|
|
||||||
validators=[InputRequired(), PhoneNumber()],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
service_branch = SelectField(
|
service_branch = USER_FIELDS["service_branch"]
|
||||||
"Service Branch or Agency",
|
|
||||||
description="Which service or organization do you belong to within the DoD?",
|
citizenship = inherit_field(
|
||||||
choices=SERVICE_BRANCHES,
|
USER_FIELDS["citizenship"], append_validators=[InputRequired()]
|
||||||
)
|
)
|
||||||
|
|
||||||
citizenship = RadioField(
|
designation = inherit_field(
|
||||||
description="What is your citizenship status?",
|
USER_FIELDS["designation"], append_validators=[InputRequired()]
|
||||||
choices=[
|
|
||||||
("United States", "United States"),
|
|
||||||
("Foreign National", "Foreign National"),
|
|
||||||
("Other", "Other"),
|
|
||||||
],
|
|
||||||
validators=[InputRequired()],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
designation = RadioField(
|
date_latest_training = inherit_field(
|
||||||
"Designation of Person",
|
USER_FIELDS["date_latest_training"], append_validators=[InputRequired()]
|
||||||
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",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user