show financial verification data for existing task order
This commit is contained in:
parent
8f5d6defce
commit
a7fbd386e0
@ -39,3 +39,10 @@ class TaskOrder(Base):
|
|||||||
@property
|
@property
|
||||||
def verified(self):
|
def verified(self):
|
||||||
return self.source == Source.EDA
|
return self.source == Source.EDA
|
||||||
|
|
||||||
|
def to_dictionary(self):
|
||||||
|
return {
|
||||||
|
c.name: getattr(self, c.name)
|
||||||
|
for c in self.__table__.columns
|
||||||
|
if c.name not in ["id", "attachment_id"]
|
||||||
|
}
|
||||||
|
@ -14,14 +14,6 @@ from atst.domain.exceptions import NotFoundError
|
|||||||
from atst.forms.ccpo_review import CCPOReviewForm
|
from atst.forms.ccpo_review import CCPOReviewForm
|
||||||
|
|
||||||
|
|
||||||
def task_order_dictionary(task_order):
|
|
||||||
return {
|
|
||||||
c.name: getattr(task_order, c.name)
|
|
||||||
for c in task_order.__table__.columns
|
|
||||||
if c.name not in ["id", "attachment_id"]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def render_approval(request, form=None):
|
def render_approval(request, form=None):
|
||||||
data = request.body
|
data = request.body
|
||||||
pending_final_approval = Requests.is_pending_ccpo_approval(request)
|
pending_final_approval = Requests.is_pending_ccpo_approval(request)
|
||||||
@ -29,7 +21,7 @@ def render_approval(request, form=None):
|
|||||||
Requests.is_pending_ccpo_acceptance(request) or pending_final_approval
|
Requests.is_pending_ccpo_acceptance(request) or pending_final_approval
|
||||||
)
|
)
|
||||||
if pending_final_approval and request.task_order:
|
if pending_final_approval and request.task_order:
|
||||||
data["task_order"] = task_order_dictionary(request.task_order)
|
data["task_order"] = request.task_order.to_dictionary()
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"requests/approval.html",
|
"requests/approval.html",
|
||||||
|
@ -6,6 +6,13 @@ from atst.domain.requests import Requests
|
|||||||
from atst.forms.financial import FinancialForm, ExtendedFinancialForm
|
from atst.forms.financial import FinancialForm, ExtendedFinancialForm
|
||||||
|
|
||||||
|
|
||||||
|
def task_order_data(task_order):
|
||||||
|
data = task_order.to_dictionary()
|
||||||
|
data["task_order_number"] = task_order.number
|
||||||
|
data["funding_type"] = task_order.funding_type.value
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
def financial_form(data):
|
def financial_form(data):
|
||||||
if http_request.args.get("extended"):
|
if http_request.args.get("extended"):
|
||||||
return ExtendedFinancialForm(data=data)
|
return ExtendedFinancialForm(data=data)
|
||||||
@ -16,7 +23,11 @@ def financial_form(data):
|
|||||||
@requests_bp.route("/requests/verify/<string:request_id>", methods=["GET"])
|
@requests_bp.route("/requests/verify/<string:request_id>", methods=["GET"])
|
||||||
def financial_verification(request_id=None):
|
def financial_verification(request_id=None):
|
||||||
request = Requests.get(g.current_user, request_id)
|
request = Requests.get(g.current_user, request_id)
|
||||||
form = financial_form(request.body.get("financial_verification"))
|
form_data = request.body.get("financial_verification")
|
||||||
|
if request.task_order:
|
||||||
|
form_data.update(task_order_data(request.task_order))
|
||||||
|
|
||||||
|
form = financial_form(form_data)
|
||||||
return render_template(
|
return render_template(
|
||||||
"requests/financial_verification.html",
|
"requests/financial_verification.html",
|
||||||
f=form,
|
f=form,
|
||||||
|
@ -61,9 +61,7 @@ class RequestsIndex(object):
|
|||||||
if viewing_role == "ccpo":
|
if viewing_role == "ccpo":
|
||||||
return url_for("requests.approval", request_id=request.id)
|
return url_for("requests.approval", request_id=request.id)
|
||||||
elif Requests.is_pending_financial_verification(request):
|
elif Requests.is_pending_financial_verification(request):
|
||||||
return url_for(
|
return url_for("requests.financial_verification", request_id=request.id)
|
||||||
"requests.financial_verification", request_id=request.id
|
|
||||||
)
|
|
||||||
elif Requests.is_pending_financial_verification_changes(request):
|
elif Requests.is_pending_financial_verification_changes(request):
|
||||||
return url_for(
|
return url_for(
|
||||||
"requests.financial_verification", request_id=request.id, extended=True
|
"requests.financial_verification", request_id=request.id, extended=True
|
||||||
|
@ -10,7 +10,7 @@ from atst.models.request_revision import RequestRevision
|
|||||||
from atst.models.request_review import RequestReview
|
from atst.models.request_review import RequestReview
|
||||||
from atst.models.request_status_event import RequestStatusEvent, RequestStatus
|
from atst.models.request_status_event import RequestStatusEvent, RequestStatus
|
||||||
from atst.models.pe_number import PENumber
|
from atst.models.pe_number import PENumber
|
||||||
from atst.models.task_order import TaskOrder
|
from atst.models.task_order import TaskOrder, Source, FundingType
|
||||||
from atst.models.user import User
|
from atst.models.user import User
|
||||||
from atst.models.role import Role
|
from atst.models.role import Role
|
||||||
from atst.models.workspace import Workspace
|
from atst.models.workspace import Workspace
|
||||||
@ -166,6 +166,17 @@ class TaskOrderFactory(Base):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = TaskOrder
|
model = TaskOrder
|
||||||
|
|
||||||
|
source = Source.MANUAL
|
||||||
|
funding_type = FundingType.PROC
|
||||||
|
funding_type_other = None
|
||||||
|
number = "toABC123"
|
||||||
|
clin_0001 = random.randrange(100, 100000)
|
||||||
|
clin_0003 = random.randrange(100, 100000)
|
||||||
|
clin_1001 = random.randrange(100, 100000)
|
||||||
|
clin_1003 = random.randrange(100, 100000)
|
||||||
|
clin_2001 = random.randrange(100, 100000)
|
||||||
|
clin_2003 = random.randrange(100, 100000)
|
||||||
|
|
||||||
|
|
||||||
class WorkspaceFactory(Base):
|
class WorkspaceFactory(Base):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
9
tests/models/test_task_order.py
Normal file
9
tests/models/test_task_order.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
from atst.models.task_order import TaskOrder
|
||||||
|
|
||||||
|
from tests.factories import TaskOrderFactory
|
||||||
|
|
||||||
|
|
||||||
|
def test_as_dictionary():
|
||||||
|
data = TaskOrderFactory.dictionary()
|
||||||
|
real_task_order = TaskOrderFactory.create(**data)
|
||||||
|
assert real_task_order.to_dictionary() == data
|
Loading…
x
Reference in New Issue
Block a user