Merge pull request #386 from dod-ccpo/edit-user-#160268937
Edit user #160268937
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from atst.domain.roles import WORKSPACE_ROLES as WORKSPACE_ROLE_DEFINITIONS
|
||||
|
||||
SERVICE_BRANCHES = [
|
||||
(None, "Select an option"),
|
||||
("", "Select an option"),
|
||||
("Air Force, Department of the", "Air Force, Department of the"),
|
||||
("Army and Air Force Exchange Service", "Army and Air Force Exchange Service"),
|
||||
("Army, Department of the", "Army, Department of the"),
|
||||
|
@@ -1,7 +1,8 @@
|
||||
import pendulum
|
||||
from copy import deepcopy
|
||||
from wtforms.fields.html5 import DateField, EmailField, TelField
|
||||
from wtforms.fields import RadioField, StringField
|
||||
from wtforms.validators import Email, Required
|
||||
from wtforms.validators import Email, Required, Optional
|
||||
|
||||
from .fields import SelectField
|
||||
from .forms import ValidatedForm
|
||||
@@ -9,42 +10,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=[Alphabet()]),
|
||||
"last_name": StringField("Last Name", validators=[Alphabet()]),
|
||||
"email": EmailField(
|
||||
"E-mail Address",
|
||||
description="Enter your preferred contact e-mail address",
|
||||
validators=[Required(), Email()],
|
||||
)
|
||||
|
||||
phone_number = TelField(
|
||||
validators=[Email()],
|
||||
),
|
||||
"phone_number": TelField(
|
||||
"Phone Number",
|
||||
description="Enter your 10-digit U.S. phone number",
|
||||
validators=[Required(), PhoneNumber()],
|
||||
)
|
||||
|
||||
service_branch = SelectField(
|
||||
validators=[PhoneNumber()],
|
||||
),
|
||||
"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"),
|
||||
],
|
||||
validators=[Required()],
|
||||
)
|
||||
|
||||
designation = RadioField(
|
||||
),
|
||||
"designation": RadioField(
|
||||
"Designation of Person",
|
||||
description="What is your designation within the DoD?",
|
||||
choices=[
|
||||
@@ -52,19 +44,43 @@ class EditUserForm(ValidatedForm):
|
||||
("civilian", "Civilian"),
|
||||
("contractor", "Contractor"),
|
||||
],
|
||||
validators=[Required()],
|
||||
)
|
||||
|
||||
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=[
|
||||
Required(),
|
||||
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",
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
def inherit_field(unbound_field, required=True):
|
||||
kwargs = deepcopy(unbound_field.kwargs)
|
||||
if not "validators" in kwargs:
|
||||
kwargs["validators"] = []
|
||||
|
||||
if required:
|
||||
kwargs["validators"].append(Required())
|
||||
else:
|
||||
kwargs["validators"].append(Optional())
|
||||
|
||||
return unbound_field.field_class(*unbound_field.args, **kwargs)
|
||||
|
||||
|
||||
class EditUserForm(ValidatedForm):
|
||||
first_name = inherit_field(USER_FIELDS["first_name"])
|
||||
last_name = inherit_field(USER_FIELDS["last_name"])
|
||||
email = inherit_field(USER_FIELDS["email"])
|
||||
phone_number = inherit_field(USER_FIELDS["phone_number"], required=False)
|
||||
service_branch = inherit_field(USER_FIELDS["service_branch"], required=False)
|
||||
citizenship = inherit_field(USER_FIELDS["citizenship"], required=False)
|
||||
designation = inherit_field(USER_FIELDS["designation"], required=False)
|
||||
date_latest_training = inherit_field(
|
||||
USER_FIELDS["date_latest_training"], required=False
|
||||
)
|
||||
|
@@ -1,17 +1,18 @@
|
||||
import pendulum
|
||||
from wtforms.fields.html5 import DateField, EmailField, IntegerField, TelField
|
||||
from wtforms.fields.html5 import DateField, EmailField, IntegerField
|
||||
from wtforms.fields import BooleanField, RadioField, StringField, TextAreaField
|
||||
from wtforms.validators import Email, Length, Optional, InputRequired, DataRequired
|
||||
|
||||
from .fields import SelectField
|
||||
from .forms import ValidatedForm
|
||||
from .edit_user import USER_FIELDS, inherit_field
|
||||
from .data import (
|
||||
SERVICE_BRANCHES,
|
||||
ASSISTANCE_ORG_TYPES,
|
||||
DATA_TRANSFER_AMOUNTS,
|
||||
COMPLETION_DATE_RANGES,
|
||||
)
|
||||
from .validators import Alphabet, DateRange, PhoneNumber, IsNumber
|
||||
from .validators import DateRange, IsNumber
|
||||
from atst.domain.requests import Requests
|
||||
|
||||
|
||||
@@ -162,58 +163,21 @@ class DetailsOfUseForm(ValidatedForm):
|
||||
|
||||
|
||||
class InformationAboutYouForm(ValidatedForm):
|
||||
fname_request = StringField("First Name", validators=[InputRequired(), Alphabet()])
|
||||
fname_request = inherit_field(USER_FIELDS["first_name"])
|
||||
|
||||
lname_request = StringField("Last Name", validators=[InputRequired(), Alphabet()])
|
||||
lname_request = inherit_field(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"])
|
||||
|
||||
service_branch = SelectField(
|
||||
"Service Branch or Agency",
|
||||
description="Which service or organization do you belong to within the DoD?",
|
||||
choices=SERVICE_BRANCHES,
|
||||
)
|
||||
service_branch = inherit_field(USER_FIELDS["service_branch"])
|
||||
|
||||
citizenship = RadioField(
|
||||
description="What is your citizenship status?",
|
||||
choices=[
|
||||
("United States", "United States"),
|
||||
("Foreign National", "Foreign National"),
|
||||
("Other", "Other"),
|
||||
],
|
||||
validators=[InputRequired()],
|
||||
)
|
||||
citizenship = inherit_field(USER_FIELDS["citizenship"])
|
||||
|
||||
designation = RadioField(
|
||||
"Designation of Person",
|
||||
description="What is your designation within the DoD?",
|
||||
choices=[
|
||||
("military", "Military"),
|
||||
("civilian", "Civilian"),
|
||||
("contractor", "Contractor"),
|
||||
],
|
||||
validators=[InputRequired()],
|
||||
)
|
||||
designation = inherit_field(USER_FIELDS["designation"])
|
||||
|
||||
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"])
|
||||
|
||||
|
||||
class WorkspaceOwnerForm(ValidatedForm):
|
||||
|
@@ -6,6 +6,9 @@ from datetime import datetime
|
||||
|
||||
def DateRange(lower_bound=None, upper_bound=None, message=None):
|
||||
def _date_range(form, field):
|
||||
if field.data is None:
|
||||
return
|
||||
|
||||
now = pendulum.now().date()
|
||||
|
||||
if isinstance(field.data, str):
|
||||
|
Reference in New Issue
Block a user