run reformatter
This commit is contained in:
parent
24cbb90ce2
commit
ebac93bc23
@ -76,9 +76,10 @@ class Requests(object):
|
|||||||
filters.append(Request.creator == creator)
|
filters.append(Request.creator == creator)
|
||||||
|
|
||||||
requests = (
|
requests = (
|
||||||
db.session.query(Request).filter(*filters).order_by(
|
db.session.query(Request)
|
||||||
Request.time_created.desc()
|
.filter(*filters)
|
||||||
).all()
|
.order_by(Request.time_created.desc())
|
||||||
|
.all()
|
||||||
)
|
)
|
||||||
return requests
|
return requests
|
||||||
|
|
||||||
@ -118,9 +119,10 @@ class Requests(object):
|
|||||||
# Query for request matching id, acquiring a row-level write lock.
|
# Query for request matching id, acquiring a row-level write lock.
|
||||||
# https://www.postgresql.org/docs/10/static/sql-select.html#SQL-FOR-UPDATE-SHARE
|
# https://www.postgresql.org/docs/10/static/sql-select.html#SQL-FOR-UPDATE-SHARE
|
||||||
return (
|
return (
|
||||||
db.session.query(Request).filter_by(id=request_id).with_for_update(
|
db.session.query(Request)
|
||||||
of=Request
|
.filter_by(id=request_id)
|
||||||
).one()
|
.with_for_update(of=Request)
|
||||||
|
.one()
|
||||||
)
|
)
|
||||||
|
|
||||||
except NoResultFound:
|
except NoResultFound:
|
||||||
@ -154,13 +156,16 @@ class Requests(object):
|
|||||||
return dollar_value < cls.AUTO_APPROVE_THRESHOLD
|
return dollar_value < cls.AUTO_APPROVE_THRESHOLD
|
||||||
|
|
||||||
_VALID_SUBMISSION_STATUSES = [
|
_VALID_SUBMISSION_STATUSES = [
|
||||||
RequestStatus.STARTED, RequestStatus.CHANGES_REQUESTED
|
RequestStatus.STARTED,
|
||||||
|
RequestStatus.CHANGES_REQUESTED,
|
||||||
]
|
]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def should_allow_submission(cls, request):
|
def should_allow_submission(cls, request):
|
||||||
all_request_sections = [
|
all_request_sections = [
|
||||||
"details_of_use", "information_about_you", "primary_poc"
|
"details_of_use",
|
||||||
|
"information_about_you",
|
||||||
|
"primary_poc",
|
||||||
]
|
]
|
||||||
existing_request_sections = request.body.keys()
|
existing_request_sections = request.body.keys()
|
||||||
return request.status in Requests._VALID_SUBMISSION_STATUSES and all(
|
return request.status in Requests._VALID_SUBMISSION_STATUSES and all(
|
||||||
@ -241,9 +246,8 @@ WHERE requests_with_status.status = :status
|
|||||||
else:
|
else:
|
||||||
task_order_number = request_data.get("task_order_number")
|
task_order_number = request_data.get("task_order_number")
|
||||||
|
|
||||||
if (
|
if "task_order" in request_data and isinstance(
|
||||||
"task_order" in request_data
|
request_data["task_order"], FileStorage
|
||||||
and isinstance(request_data["task_order"], FileStorage)
|
|
||||||
):
|
):
|
||||||
task_order_data["pdf"] = request_data.pop("task_order")
|
task_order_data["pdf"] = request_data.pop("task_order")
|
||||||
|
|
||||||
|
@ -7,15 +7,12 @@ from .validators import Alphabet, PhoneNumber
|
|||||||
|
|
||||||
|
|
||||||
class CCPOReviewForm(ValidatedForm):
|
class CCPOReviewForm(ValidatedForm):
|
||||||
comments = TextAreaField(
|
comments = TextAreaField("Comments (optional)")
|
||||||
"Comments (optional)",
|
|
||||||
)
|
|
||||||
fname_mao = StringField("First Name", validators=[Required(), Alphabet()])
|
fname_mao = StringField("First Name", validators=[Required(), Alphabet()])
|
||||||
lname_mao = StringField("Last Name", validators=[Required(), Alphabet()])
|
lname_mao = StringField("Last Name", validators=[Required(), Alphabet()])
|
||||||
email_mao = EmailField("Mission Owner e-mail (optional)", validators=[Email()])
|
email_mao = EmailField("Mission Owner e-mail (optional)", validators=[Email()])
|
||||||
phone_mao = TelField(
|
phone_mao = TelField(
|
||||||
"Mission Owner phone number (optional)",
|
"Mission Owner phone number (optional)", validators=[PhoneNumber()]
|
||||||
validators=[PhoneNumber()],
|
|
||||||
)
|
)
|
||||||
fname_ccpo = StringField("First Name", validators=[Required(), Alphabet()])
|
fname_ccpo = StringField("First Name", validators=[Required(), Alphabet()])
|
||||||
lname_ccpo = StringField("Last Name", validators=[Required(), Alphabet()])
|
lname_ccpo = StringField("Last Name", validators=[Required(), Alphabet()])
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
from flask import render_template, g, Response, request as http_request, redirect, url_for
|
from flask import (
|
||||||
|
render_template,
|
||||||
|
g,
|
||||||
|
Response,
|
||||||
|
request as http_request,
|
||||||
|
redirect,
|
||||||
|
url_for,
|
||||||
|
)
|
||||||
from flask import current_app as app
|
from flask import current_app as app
|
||||||
|
|
||||||
from . import requests_bp
|
from . import requests_bp
|
||||||
|
@ -76,7 +76,9 @@ class RequestsIndex(object):
|
|||||||
edit_link = url_for(
|
edit_link = url_for(
|
||||||
"requests.financial_verification", request_id=request.id
|
"requests.financial_verification", request_id=request.id
|
||||||
)
|
)
|
||||||
elif Requests.is_pending_ccpo_acceptance(request) or Requests.is_pending_ccpo_approval(request):
|
elif Requests.is_pending_ccpo_acceptance(
|
||||||
|
request
|
||||||
|
) or Requests.is_pending_ccpo_approval(request):
|
||||||
edit_link = url_for("requests.view_pending_request", request_id=request.id)
|
edit_link = url_for("requests.view_pending_request", request_id=request.id)
|
||||||
else:
|
else:
|
||||||
edit_link = url_for(
|
edit_link = url_for(
|
||||||
|
@ -188,4 +188,3 @@ def test_accept_for_financial_verification():
|
|||||||
assert request.status == RequestStatus.PENDING_FINANCIAL_VERIFICATION
|
assert request.status == RequestStatus.PENDING_FINANCIAL_VERIFICATION
|
||||||
current_review = request.latest_status.review
|
current_review = request.latest_status.review
|
||||||
assert current_review.fname_mao == review_data["fname_mao"]
|
assert current_review.fname_mao == review_data["fname_mao"]
|
||||||
|
|
||||||
|
@ -70,7 +70,9 @@ class RequestReviewFactory(Base):
|
|||||||
fname_mao = factory.Faker("first_name")
|
fname_mao = factory.Faker("first_name")
|
||||||
lname_mao = factory.Faker("last_name")
|
lname_mao = factory.Faker("last_name")
|
||||||
email_mao = factory.Faker("email")
|
email_mao = factory.Faker("email")
|
||||||
phone_mao = factory.LazyFunction(lambda: "".join(random.choices(string.digits, k=10)))
|
phone_mao = factory.LazyFunction(
|
||||||
|
lambda: "".join(random.choices(string.digits, k=10))
|
||||||
|
)
|
||||||
fname_ccpo = factory.Faker("first_name")
|
fname_ccpo = factory.Faker("first_name")
|
||||||
lname_ccpo = factory.Faker("last_name")
|
lname_ccpo = factory.Faker("last_name")
|
||||||
|
|
||||||
|
@ -6,7 +6,10 @@ from atst.models.request_status_event import RequestStatus
|
|||||||
from atst.domain.roles import Roles
|
from atst.domain.roles import Roles
|
||||||
|
|
||||||
from tests.factories import (
|
from tests.factories import (
|
||||||
RequestFactory, TaskOrderFactory, UserFactory, RequestReviewFactory
|
RequestFactory,
|
||||||
|
TaskOrderFactory,
|
||||||
|
UserFactory,
|
||||||
|
RequestReviewFactory,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,13 +30,11 @@ def test_ccpo_sees_approval_screen():
|
|||||||
request = RequestFactory.create()
|
request = RequestFactory.create()
|
||||||
Requests.submit(request)
|
Requests.submit(request)
|
||||||
ccpo_context = RequestsIndex(ccpo).execute()
|
ccpo_context = RequestsIndex(ccpo).execute()
|
||||||
assert (
|
assert ccpo_context["requests"][0]["edit_link"] == url_for(
|
||||||
ccpo_context["requests"][0]["edit_link"]
|
"requests.approval", request_id=request.id
|
||||||
== url_for("requests.approval", request_id=request.id)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
mo_context = RequestsIndex(request.creator).execute()
|
mo_context = RequestsIndex(request.creator).execute()
|
||||||
assert (
|
assert mo_context["requests"][0]["edit_link"] != url_for(
|
||||||
mo_context["requests"][0]["edit_link"]
|
"requests.approval", request_id=request.id
|
||||||
!= url_for("requests.approval", request_id=request.id)
|
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user