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
|
||||
def verified(self):
|
||||
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
|
||||
|
||||
|
||||
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):
|
||||
data = request.body
|
||||
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
|
||||
)
|
||||
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(
|
||||
"requests/approval.html",
|
||||
|
@ -6,6 +6,13 @@ from atst.domain.requests import Requests
|
||||
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):
|
||||
if http_request.args.get("extended"):
|
||||
return ExtendedFinancialForm(data=data)
|
||||
@ -16,7 +23,11 @@ def financial_form(data):
|
||||
@requests_bp.route("/requests/verify/<string:request_id>", methods=["GET"])
|
||||
def financial_verification(request_id=None):
|
||||
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(
|
||||
"requests/financial_verification.html",
|
||||
f=form,
|
||||
|
@ -61,9 +61,7 @@ class RequestsIndex(object):
|
||||
if viewing_role == "ccpo":
|
||||
return url_for("requests.approval", request_id=request.id)
|
||||
elif Requests.is_pending_financial_verification(request):
|
||||
return url_for(
|
||||
"requests.financial_verification", request_id=request.id
|
||||
)
|
||||
return url_for("requests.financial_verification", request_id=request.id)
|
||||
elif Requests.is_pending_financial_verification_changes(request):
|
||||
return url_for(
|
||||
"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_status_event import RequestStatusEvent, RequestStatus
|
||||
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.role import Role
|
||||
from atst.models.workspace import Workspace
|
||||
@ -166,6 +166,17 @@ class TaskOrderFactory(Base):
|
||||
class Meta:
|
||||
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 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