Create new template and form field
This commit is contained in:
@@ -1,16 +1,34 @@
|
||||
from wtforms.fields import StringField
|
||||
from wtforms.fields import StringField, RadioField
|
||||
from wtforms.fields.html5 import EmailField
|
||||
from wtforms.validators import Required, Email, Length
|
||||
from wtforms.validators import Required, Email, Length, Optional
|
||||
from .forms import ValidatedForm
|
||||
from .validators import IsNumber
|
||||
|
||||
|
||||
class POCForm(ValidatedForm):
|
||||
fname_poc = StringField("First Name", validators=[Required()])
|
||||
|
||||
lname_poc = StringField("Last Name", validators=[Required()])
|
||||
def validate(self, *args, **kwargs):
|
||||
if self.am_poc.data == "yes":
|
||||
self.fname_poc.validators.insert(0, Optional())
|
||||
self.lname_poc.validators.insert(0, Optional())
|
||||
self.email_poc.validators.insert(0, Optional())
|
||||
self.dodid_poc.validators.insert(0, Optional())
|
||||
|
||||
email_poc = EmailField("Email Address", validators=[Required(), Email()])
|
||||
return super(POCForm, self).validate(*args, **kwargs)
|
||||
|
||||
|
||||
am_poc = RadioField(
|
||||
"I am the technical POC.",
|
||||
choices=[("yes", "Yes"), ("no", "No")],
|
||||
default="no",
|
||||
validators=[Required()],
|
||||
)
|
||||
|
||||
fname_poc = StringField("POC First Name", validators=[Required()])
|
||||
|
||||
lname_poc = StringField("POC Last Name", validators=[Required()])
|
||||
|
||||
email_poc = EmailField("POC Email Address", validators=[Required(), Email()])
|
||||
|
||||
dodid_poc = StringField(
|
||||
"DOD ID", validators=[Required(), Length(min=10), IsNumber()]
|
||||
|
@@ -130,5 +130,14 @@ class JEDIRequestFlow(object):
|
||||
self.request_id = request.id
|
||||
|
||||
def update_request(self, section, data):
|
||||
if section == "primary_poc":
|
||||
if data.get("am_poc") == "yes":
|
||||
data = {
|
||||
"dodid_poc": self.existing_request.creator.dod_id,
|
||||
"fname_poc": self.existing_request.creator.first_name,
|
||||
"lname_poc": self.existing_request.creator.last_name,
|
||||
"email_poc": self.existing_request.creator.email
|
||||
}
|
||||
|
||||
request_data = {section: data}
|
||||
Requests.update(self.request_id, request_data)
|
||||
|
Reference in New Issue
Block a user