Update request form (#45)
* Implement OrganizationInfo form, add it to the template * Format request_new * Update "Details of Use" section * Refactor request_new * Added some new fields, but form is still WIP * Add details of use fields * Add org info fields * Add some comments * Add Financial Verification and more Details of Use fields * Update some textarea fields to single text field * WIP * Implement OrganizationInfo form, add it to the template * Format request_new * Update "Details of Use" section * Refactor request_new * Added some new fields, but form is still WIP * Add details of use fields * Add org info fields * Add some comments * Add Financial Verification and more Details of Use fields * Update some textarea fields to single text field * Format * Update fields with the correct fieldtypes * Begin updating sidenav changes * Split form into each section * adjust and skip some outdated form validation tests * break request form into multiple form objects * need to send user ID to requests-queue * use DateForm for start date in request * alter request_new handler to pass raw form data to template * change review form * Add KO and COR section titles * Update date input class name * Add a special case for the summary form. We should refactor this * Add read-only fields for review and submit section * Add minimum number validators to request form * Fix formatting * Use html5 datepicker for dates * Fix request form validators * Finish org info form * Finish POC form * Finish financial verification form * Move PE and UII to financial form * Un-skip form validation test
This commit is contained in:
29
atst/forms/validators.py
Normal file
29
atst/forms/validators.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from wtforms.validators import ValidationError
|
||||
import pendulum
|
||||
|
||||
|
||||
def DateRange(lower_bound=None, upper_bound=None, message=None):
|
||||
def _date_range(form, field):
|
||||
now = pendulum.now().date()
|
||||
|
||||
if lower_bound is not None:
|
||||
date = pendulum.parse(field.data).date()
|
||||
if (now - lower_bound) > date:
|
||||
raise ValidationError(message)
|
||||
|
||||
if upper_bound is not None:
|
||||
date = pendulum.parse(field.data).date()
|
||||
if (now + upper_bound) < date:
|
||||
raise ValidationError(message)
|
||||
|
||||
return _date_range
|
||||
|
||||
|
||||
def IsNumber(message="Please enter a valid number."):
|
||||
def _is_number(form, field):
|
||||
try:
|
||||
int(field.data)
|
||||
except ValueError:
|
||||
raise ValidationError(message)
|
||||
|
||||
return _is_number
|
Reference in New Issue
Block a user