ccpo can submit basic review
This commit is contained in:
22
atst/forms/ccpo_review.py
Normal file
22
atst/forms/ccpo_review.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from wtforms.fields.html5 import EmailField, TelField
|
||||
from wtforms.fields import StringField, TextAreaField
|
||||
from wtforms.validators import Required, Email
|
||||
|
||||
from .forms import ValidatedForm
|
||||
from .validators import Alphabet, PhoneNumber
|
||||
|
||||
|
||||
class CCPOReviewForm(ValidatedForm):
|
||||
comments = TextAreaField(
|
||||
"Comments",
|
||||
description="Add notes or comments explaining what changes are being requested or why further discussion is needed about this request.",
|
||||
)
|
||||
fname_mao = StringField("First Name", validators=[Required(), Alphabet()])
|
||||
lname_mao = StringField("Last Name", validators=[Required(), Alphabet()])
|
||||
email_mao = EmailField("Mission Owner e-mail (optional)", validators=[Email()])
|
||||
phone_mao = TelField(
|
||||
"Mission Owner phone number (optional)",
|
||||
validators=[Required(), PhoneNumber()],
|
||||
)
|
||||
fname_ccpo = StringField("First Name", validators=[Required(), Alphabet()])
|
||||
lname_ccpo = StringField("Last Name", validators=[Required(), Alphabet()])
|
@@ -1,10 +1,11 @@
|
||||
from flask import render_template, g, Response
|
||||
from flask import render_template, g, Response, request as http_request, redirect, url_for
|
||||
from flask import current_app as app
|
||||
|
||||
from . import requests_bp
|
||||
from atst.domain.requests import Requests
|
||||
from atst.domain.exceptions import NotFoundError
|
||||
from atst.domain.authz import Authorization
|
||||
from atst.forms.ccpo_review import CCPOReviewForm
|
||||
|
||||
|
||||
def task_order_dictionary(task_order):
|
||||
@@ -15,11 +16,7 @@ def task_order_dictionary(task_order):
|
||||
}
|
||||
|
||||
|
||||
@requests_bp.route("/requests/approval/<string:request_id>", methods=["GET"])
|
||||
def approval(request_id):
|
||||
request = Requests.get(g.current_user, request_id)
|
||||
Authorization.check_can_approve_request(g.current_user)
|
||||
|
||||
def render_approval(request, form=None):
|
||||
data = request.body
|
||||
if request.task_order:
|
||||
data["task_order"] = task_order_dictionary(request.task_order)
|
||||
@@ -27,13 +24,35 @@ def approval(request_id):
|
||||
return render_template(
|
||||
"requests/approval.html",
|
||||
data=data,
|
||||
request_id=request_id,
|
||||
request_id=request.id,
|
||||
status=request.status.value,
|
||||
financial_review=True,
|
||||
pdf_available=request.task_order and request.task_order.pdf,
|
||||
f=form or CCPOReviewForm(),
|
||||
)
|
||||
|
||||
|
||||
@requests_bp.route("/requests/approval/<string:request_id>", methods=["GET"])
|
||||
def approval(request_id):
|
||||
request = Requests.get(g.current_user, request_id)
|
||||
Authorization.check_can_approve_request(g.current_user)
|
||||
|
||||
return render_approval(request)
|
||||
|
||||
|
||||
@requests_bp.route("/requests/submit_approval/<string:request_id>", methods=["POST"])
|
||||
def submit_approval(request_id):
|
||||
request = Requests.get(g.current_user, request_id)
|
||||
Authorization.check_can_approve_request(g.current_user)
|
||||
|
||||
form = CCPOReviewForm(http_request.form)
|
||||
if form.validate():
|
||||
Requests.approve_for_financial_verification(request, form.data)
|
||||
return redirect(url_for("requests.requests_index"))
|
||||
else:
|
||||
return render_approval(request, form)
|
||||
|
||||
|
||||
@requests_bp.route("/requests/task_order_download/<string:request_id>", methods=["GET"])
|
||||
def task_order_pdf_download(request_id):
|
||||
request = Requests.get(g.current_user, request_id)
|
||||
|
Reference in New Issue
Block a user