Formatting

This commit is contained in:
richard-dds 2018-08-02 11:07:08 -04:00
parent 6c060c8256
commit d6b099c684
27 changed files with 215 additions and 213 deletions

View File

@ -25,7 +25,7 @@ def make_app(config):
app = Flask( app = Flask(
__name__, __name__,
template_folder=parent_dir.child("templates").absolute(), template_folder=parent_dir.child("templates").absolute(),
static_folder=parent_dir.child("static").absolute() static_folder=parent_dir.child("static").absolute(),
) )
app.config.update(config) app.config.update(config)
@ -44,23 +44,25 @@ def make_app(config):
def make_flask_callbacks(app): def make_flask_callbacks(app):
@app.before_request @app.before_request
def set_globals(): def set_globals():
g.navigationContext = 'workspace' if re.match('\/workspaces\/[A-Za-z0-9]*', request.url) else 'global' g.navigationContext = (
"workspace"
if re.match("\/workspaces\/[A-Za-z0-9]*", request.url)
else "global"
)
g.dev = os.getenv("TORNADO_ENV", "dev") == "dev" g.dev = os.getenv("TORNADO_ENV", "dev") == "dev"
g.matchesPath = lambda href: re.match('^'+href, request.path) g.matchesPath = lambda href: re.match("^" + href, request.path)
g.modalOpen = request.args.get("modal", False) g.modalOpen = request.args.get("modal", False)
g.current_user = { g.current_user = {
"id": "cce17030-4109-4719-b958-ed109dbb87c8", "id": "cce17030-4109-4719-b958-ed109dbb87c8",
"first_name": "Amanda", "first_name": "Amanda",
"last_name": "Adamson", "last_name": "Adamson",
"atat_role": "default", "atat_role": "default",
"atat_permissions": [] "atat_permissions": [],
} }
# TODO: Make me a macro # TODO: Make me a macro
def modal(self, body): def modal(self, body):
return self.render_string( return self.render_string("components/modal.html.to", body=body)
"components/modal.html.to",
body=body)
# def make_app(config, deps, **kwargs): # def make_app(config, deps, **kwargs):
@ -211,6 +213,7 @@ def make_deps(config):
), ),
} }
def map_config(config): def map_config(config):
return { return {
"ENV": config["default"]["ENVIRONMENT"], "ENV": config["default"]["ENVIRONMENT"],
@ -218,9 +221,10 @@ def map_config(config):
"PORT": int(config["default"]["PORT"]), "PORT": int(config["default"]["PORT"]),
"SQLALCHEMY_DATABASE_URI": config["default"]["DATABASE_URI"], "SQLALCHEMY_DATABASE_URI": config["default"]["DATABASE_URI"],
"SQLALCHEMY_TRACK_MODIFICATIONS": False, "SQLALCHEMY_TRACK_MODIFICATIONS": False,
**config["default"] **config["default"],
} }
def make_config(): def make_config():
BASE_CONFIG_FILENAME = os.path.join(os.path.dirname(__file__), "../config/base.ini") BASE_CONFIG_FILENAME = os.path.join(os.path.dirname(__file__), "../config/base.ini")
ENV_CONFIG_FILENAME = os.path.join( ENV_CONFIG_FILENAME = os.path.join(

View File

@ -5,7 +5,6 @@ from .exceptions import NotFoundError
class PENumbers(object): class PENumbers(object):
def __init__(self, db_session): def __init__(self, db_session):
self.db_session = db_session self.db_session = db_session
@ -19,8 +18,7 @@ class PENumbers(object):
def create_many(self, list_of_pe_numbers): def create_many(self, list_of_pe_numbers):
stmt = insert(PENumber).values(list_of_pe_numbers) stmt = insert(PENumber).values(list_of_pe_numbers)
do_update = stmt.on_conflict_do_update( do_update = stmt.on_conflict_do_update(
index_elements=["number"], index_elements=["number"], set_=dict(description=stmt.excluded.description)
set_=dict(description=stmt.excluded.description)
) )
self.db_session.execute(do_update) self.db_session.execute(do_update)
self.db_session.commit() self.db_session.commit()

View File

@ -102,7 +102,9 @@ class Requests(object):
request.body = deep_merge(request_delta, request.body) request.body = deep_merge(request_delta, request.body)
if Requests.should_allow_submission(request): if Requests.should_allow_submission(request):
request.status_events.append(RequestStatusEvent(new_status="pending_submission")) request.status_events.append(
RequestStatusEvent(new_status="pending_submission")
)
# Without this, sqlalchemy won't notice the change to request.body, # Without this, sqlalchemy won't notice the change to request.body,
# since it doesn't track dictionary mutations by default. # since it doesn't track dictionary mutations by default.

View File

@ -5,13 +5,14 @@ from .exceptions import NotFoundError
class TaskOrders(object): class TaskOrders(object):
def __init__(self, db_session): def __init__(self, db_session):
self.db_session = db_session self.db_session = db_session
def get(self, order_number): def get(self, order_number):
try: try:
task_order = self.db_session.query(TaskOrder).filter_by(number=order_number).one() task_order = (
self.db_session.query(TaskOrder).filter_by(number=order_number).one()
)
except NoResultFound: except NoResultFound:
raise NotFoundError("task_order") raise NotFoundError("task_order")

View File

@ -85,7 +85,7 @@ class MockEDAClient(EDAClientBase):
"location": "https://docsrv1.nit.disa.mil:443/eda/enforcer/C0414345.PDF?ver=1.4&loc=Y29udHJhY3RzL29nZGVuL3ZlbmRvci8xOTk4LzA5LzE0L0MwNDE0MzQ1LlBERg==&sourceurl=aHR0cHM6Ly9lZGE0Lm5pdC5kaXNhLm1pbC9wbHMvdXNlci9uZXdfYXBwLkdldF9Eb2M_cFRhYmxlX0lEPTImcFJlY29yZF9LZXk9OEE2ODExNjM2RUY5NkU2M0UwMzQwMDYwQjBCMjgyNkM=&uid=6CFC2B2322E86FD5E054002264936E3C&qid=19344159&signed=G&qdate=20180529194407GMT&token=6xQICrrrfIMciEJSpXmfsAYrToM=", "location": "https://docsrv1.nit.disa.mil:443/eda/enforcer/C0414345.PDF?ver=1.4&loc=Y29udHJhY3RzL29nZGVuL3ZlbmRvci8xOTk4LzA5LzE0L0MwNDE0MzQ1LlBERg==&sourceurl=aHR0cHM6Ly9lZGE0Lm5pdC5kaXNhLm1pbC9wbHMvdXNlci9uZXdfYXBwLkdldF9Eb2M_cFRhYmxlX0lEPTImcFJlY29yZF9LZXk9OEE2ODExNjM2RUY5NkU2M0UwMzQwMDYwQjBCMjgyNkM=&uid=6CFC2B2322E86FD5E054002264936E3C&qid=19344159&signed=G&qdate=20180529194407GMT&token=6xQICrrrfIMciEJSpXmfsAYrToM=",
"pay_dodaac": None, "pay_dodaac": None,
"pco_mod": "02", "pco_mod": "02",
"amount": 2000000 "amount": 2000000,
} }
else: else:
return None return None

View File

@ -7,10 +7,7 @@ import pendulum
class DateField(DateField): class DateField(DateField):
def _value(self): def _value(self):
if self.data: if self.data:
date_formats = [ date_formats = ["YYYY-MM-DD", "MM/DD/YYYY"]
"YYYY-MM-DD",
"MM/DD/YYYY"
]
for _format in date_formats: for _format in date_formats:
try: try:
return pendulum.from_format(self.data, _format).date() return pendulum.from_format(self.data, _format).date()

View File

@ -12,13 +12,17 @@ from .fields import NewlineListField
from .forms import ValidatedForm from .forms import ValidatedForm
PE_REGEX = re.compile(r""" PE_REGEX = re.compile(
r"""
(0?\d) # program identifier (0?\d) # program identifier
(0?\d) # category (0?\d) # category
(\d) # activity (\d) # activity
(\d+) # sponsor element (\d+) # sponsor element
(.+) # service (.+) # service
""", re.X) """,
re.X,
)
def suggest_pe_id(pe_id): def suggest_pe_id(pe_id):
suggestion = pe_id suggestion = pe_id
@ -45,7 +49,7 @@ def validate_pe_id(field, existing_request, pe_numbers_repo):
"We couldn't find that PE number. {}" "We couldn't find that PE number. {}"
"If you have double checked it you can submit anyway. " "If you have double checked it you can submit anyway. "
"Your request will need to go through a manual review." "Your request will need to go through a manual review."
).format("Did you mean \"{}\"? ".format(suggestion) if suggestion else "") ).format('Did you mean "{}"? '.format(suggestion) if suggestion else "")
field.errors.append(error_str) field.errors.append(error_str)
return False return False
@ -53,10 +57,9 @@ def validate_pe_id(field, existing_request, pe_numbers_repo):
class FinancialForm(ValidatedForm): class FinancialForm(ValidatedForm):
def perform_extra_validation(self, existing_request, pe_numbers_repo): def perform_extra_validation(self, existing_request, pe_numbers_repo):
valid = True valid = True
if not existing_request or existing_request.get('pe_id') != self.pe_id.data: if not existing_request or existing_request.get("pe_id") != self.pe_id.data:
valid = yield validate_pe_id(self.pe_id, existing_request, pe_numbers_repo) valid = yield validate_pe_id(self.pe_id, existing_request, pe_numbers_repo)
return valid return valid
@ -68,9 +71,7 @@ class FinancialForm(ValidatedForm):
"Unique Item Identifier (UII)s related to your application(s) if you already have them." "Unique Item Identifier (UII)s related to your application(s) if you already have them."
) )
pe_id = StringField( pe_id = StringField("Program Element (PE) Number related to your request")
"Program Element (PE) Number related to your request"
)
treasury_code = StringField("Program Treasury Code") treasury_code = StringField("Program Treasury Code")
@ -116,11 +117,13 @@ class FinancialForm(ValidatedForm):
) )
clin_0001 = StringField( clin_0001 = StringField(
"<dl><dt>CLIN 0001</dt> - <dd>Unclassified IaaS and PaaS Amount</dd></dl>", validators=[Required()] "<dl><dt>CLIN 0001</dt> - <dd>Unclassified IaaS and PaaS Amount</dd></dl>",
validators=[Required()],
) )
clin_0003 = StringField( clin_0003 = StringField(
"<dl><dt>CLIN 0003</dt> - <dd>Unclassified Cloud Support Package</dd></dl>", validators=[Required()] "<dl><dt>CLIN 0003</dt> - <dd>Unclassified Cloud Support Package</dd></dl>",
validators=[Required()],
) )
clin_1001 = StringField( clin_1001 = StringField(

View File

@ -4,7 +4,6 @@ from flask_wtf import FlaskForm
class ValidatedForm(FlaskForm): class ValidatedForm(FlaskForm):
def perform_extra_validation(self, *args, **kwargs): def perform_extra_validation(self, *args, **kwargs):
"""Performs any applicable extra validation. Must """Performs any applicable extra validation. Must
return True if the form is valid or False otherwise.""" return True if the form is valid or False otherwise."""

View File

@ -8,30 +8,15 @@ from .validators import DateRange, PhoneNumber, Alphabet
class OrgForm(ValidatedForm): class OrgForm(ValidatedForm):
fname_request = StringField( fname_request = StringField("First Name", validators=[Required(), Alphabet()])
"First Name",
validators=[Required(), Alphabet()]
)
lname_request = StringField( lname_request = StringField("Last Name", validators=[Required(), Alphabet()])
"Last Name",
validators=[Required(), Alphabet()]
)
email_request = EmailField( email_request = EmailField("Email Address", validators=[Required(), Email()])
"Email Address",
validators=[Required(), Email()]
)
phone_number = TelField( phone_number = TelField("Phone Number", validators=[Required(), PhoneNumber()])
"Phone Number",
validators=[Required(), PhoneNumber()]
)
service_branch = StringField( service_branch = StringField("Service Branch or Agency", validators=[Required()])
"Service Branch or Agency",
validators=[Required()]
)
citizenship = RadioField( citizenship = RadioField(
choices=[ choices=[

View File

@ -6,22 +6,12 @@ from .validators import IsNumber, Alphabet
class POCForm(ValidatedForm): class POCForm(ValidatedForm):
fname_poc = StringField( fname_poc = StringField("POC First Name", validators=[Required()])
"POC First Name",
validators=[Required()]
)
lname_poc = StringField( lname_poc = StringField("POC Last Name", validators=[Required()])
"POC Last Name",
validators=[Required()]
)
email_poc = EmailField( email_poc = EmailField("POC Email Address", validators=[Required(), Email()])
"POC Email Address",
validators=[Required(), Email()]
)
dodid_poc = StringField( dodid_poc = StringField(
"DOD ID", "DOD ID", validators=[Required(), Length(min=10), IsNumber()]
validators=[Required(), Length(min=10), IsNumber()]
) )

View File

@ -14,18 +14,21 @@ class RequestForm(ValidatedForm):
"DoD Component", "DoD Component",
description="Identify the DoD component that is requesting access to the JEDI Cloud", description="Identify the DoD component that is requesting access to the JEDI Cloud",
choices=[ choices=[
("null","Select an option"), ("null", "Select an option"),
("us_air_force","US Air Force"), ("us_air_force", "US Air Force"),
("us_army","US Army"), ("us_army", "US Army"),
("us_navy","US Navy"), ("us_navy", "US Navy"),
("us_marine_corps","US Marine Corps"), ("us_marine_corps", "US Marine Corps"),
("joint_chiefs_of_staff","Joint Chiefs of Staff")], ("joint_chiefs_of_staff", "Joint Chiefs of Staff"),
],
) )
jedi_usage = TextAreaField( jedi_usage = TextAreaField(
"JEDI Usage", "JEDI Usage",
description="Briefly describe how you are expecting to use the JEDI Cloud", description="Briefly describe how you are expecting to use the JEDI Cloud",
render_kw={"placeholder": "e.g. We are migrating XYZ application to the cloud so that..."}, render_kw={
"placeholder": "e.g. We are migrating XYZ application to the cloud so that..."
},
) )
# Details of Use: Cloud Readiness # Details of Use: Cloud Readiness
@ -41,7 +44,7 @@ class RequestForm(ValidatedForm):
rationalization_software_systems = RadioField( rationalization_software_systems = RadioField(
"Have you completed a “rationalization” of your software systems to move to the cloud?", "Have you completed a “rationalization” of your software systems to move to the cloud?",
choices=[("yes", "Yes"), ("no", "No"), ("in_progress","In Progress")], choices=[("yes", "Yes"), ("no", "No"), ("in_progress", "In Progress")],
) )
technical_support_team = RadioField( technical_support_team = RadioField(
@ -52,40 +55,43 @@ class RequestForm(ValidatedForm):
organization_providing_assistance = RadioField( # this needs to be updated to use checkboxes instead of radio organization_providing_assistance = RadioField( # this needs to be updated to use checkboxes instead of radio
"If you are receiving migration assistance, indicate the type of organization providing assistance below:", "If you are receiving migration assistance, indicate the type of organization providing assistance below:",
choices=[ choices=[
("in_house_staff","In-house staff"), ("in_house_staff", "In-house staff"),
("contractor","Contractor"), ("contractor", "Contractor"),
("other_dod_organization","Other DoD organization")], ("other_dod_organization", "Other DoD organization"),
],
) )
engineering_assessment = RadioField( engineering_assessment = RadioField(
description="Have you completed an engineering assessment of your software systems for cloud readiness?", description="Have you completed an engineering assessment of your software systems for cloud readiness?",
choices=[("yes", "Yes"), ("no", "No"), ("in_progress","In Progress")], choices=[("yes", "Yes"), ("no", "No"), ("in_progress", "In Progress")],
) )
data_transfers = SelectField( data_transfers = SelectField(
description="How much data is being transferred to the cloud?", description="How much data is being transferred to the cloud?",
choices=[ choices=[
("null","Select an option"), ("null", "Select an option"),
("less_than_100gb","Less than 100GB"), ("less_than_100gb", "Less than 100GB"),
("100gb-500gb","100GB-500GB"), ("100gb-500gb", "100GB-500GB"),
("500gb-1tb","500GB-1TB"), ("500gb-1tb", "500GB-1TB"),
("1tb-50tb","1TB-50TB"), ("1tb-50tb", "1TB-50TB"),
("50tb-100tb","50TB-100TB"), ("50tb-100tb", "50TB-100TB"),
("100tb-500tb","100TB-500TB"), ("100tb-500tb", "100TB-500TB"),
("500tb-1pb","500TB-1PB"), ("500tb-1pb", "500TB-1PB"),
("1pb-5pb","1PB-5PB"), ("1pb-5pb", "1PB-5PB"),
("5pb-10pb","5PB-10PB"), ("5pb-10pb", "5PB-10PB"),
("above_10pb","Above 10PB")], ("above_10pb", "Above 10PB"),
],
) )
expected_completion_date = SelectField( expected_completion_date = SelectField(
description="When do you expect to complete your migration to the JEDI Cloud?", description="When do you expect to complete your migration to the JEDI Cloud?",
choices=[ choices=[
("null","Select an option"), ("null", "Select an option"),
("less_than_1_month","Less than 1 month"), ("less_than_1_month", "Less than 1 month"),
("1_to_3_months","1-3 months"), ("1_to_3_months", "1-3 months"),
("3_to_6_months","3-6 months"), ("3_to_6_months", "3-6 months"),
("above_12_months","Above 12 months")], ("above_12_months", "Above 12 months"),
],
) )
cloud_native = RadioField( cloud_native = RadioField(
@ -96,7 +102,7 @@ class RequestForm(ValidatedForm):
# Details of Use: Financial Usage # Details of Use: Financial Usage
estimated_monthly_spend = IntegerField( estimated_monthly_spend = IntegerField(
"Estimated monthly spend", "Estimated monthly spend",
description="Use the <a href=\"#\">JEDI CSP Calculator</a> to estimate your monthly cloud resource usage and enter the dollar amount below. Note these estimates are for initial approval only. After the request is approved, you will be asked to provide a valid Task Order number with specific CLIN amounts for cloud services." description='Use the <a href="#">JEDI CSP Calculator</a> to estimate your monthly cloud resource usage and enter the dollar amount below. Note these estimates are for initial approval only. After the request is approved, you will be asked to provide a valid Task Order number with specific CLIN amounts for cloud services.',
) )
dollar_value = IntegerField( dollar_value = IntegerField(
@ -105,17 +111,13 @@ class RequestForm(ValidatedForm):
) )
number_user_sessions = IntegerField( number_user_sessions = IntegerField(
description="How many user sessions do you expect on these systems each day?", description="How many user sessions do you expect on these systems each day?"
) )
average_daily_traffic = IntegerField( average_daily_traffic = IntegerField(
description="What is the average daily traffic you expect the systems under this cloud contract to use?", description="What is the average daily traffic you expect the systems under this cloud contract to use?"
) )
start_date = DateField( start_date = DateField(
description="When do you expect to start using the JEDI Cloud (not for billing purposes)?", description="When do you expect to start using the JEDI Cloud (not for billing purposes)?"
) )

View File

@ -6,7 +6,6 @@ helpers = {"assets": None}
class BaseHandler(tornado.web.RequestHandler): class BaseHandler(tornado.web.RequestHandler):
def get_template_namespace(self): def get_template_namespace(self):
ns = super(BaseHandler, self).get_template_namespace() ns = super(BaseHandler, self).get_template_namespace()
helpers["config"] = self.application.config helpers["config"] = self.application.config

View File

@ -8,42 +8,42 @@ _DEV_USERS = {
"id": "164497f6-c1ea-4f42-a5ef-101da278c012", "id": "164497f6-c1ea-4f42-a5ef-101da278c012",
"first_name": "Sam", "first_name": "Sam",
"last_name": "Seeceepio", "last_name": "Seeceepio",
"atat_role": "ccpo" "atat_role": "ccpo",
}, },
"amanda": { "amanda": {
"id": "cce17030-4109-4719-b958-ed109dbb87c8", "id": "cce17030-4109-4719-b958-ed109dbb87c8",
"first_name": "Amanda", "first_name": "Amanda",
"last_name": "Adamson", "last_name": "Adamson",
"atat_role": "default" "atat_role": "default",
}, },
"brandon": { "brandon": {
"id": "66ebf7b8-cbf0-4ed8-a102-5f105330df75", "id": "66ebf7b8-cbf0-4ed8-a102-5f105330df75",
"first_name": "Brandon", "first_name": "Brandon",
"last_name": "Buchannan", "last_name": "Buchannan",
"atat_role": "default" "atat_role": "default",
}, },
"christina": { "christina": {
"id": "7707b9f2-5945-49ae-967a-be65baa88baf", "id": "7707b9f2-5945-49ae-967a-be65baa88baf",
"first_name": "Christina", "first_name": "Christina",
"last_name": "Collins", "last_name": "Collins",
"atat_role": "default" "atat_role": "default",
}, },
"dominick": { "dominick": {
"id": "6978ac0c-442a-46aa-a0c3-ff17b5ec2a8c", "id": "6978ac0c-442a-46aa-a0c3-ff17b5ec2a8c",
"first_name": "Dominick", "first_name": "Dominick",
"last_name": "Domingo", "last_name": "Domingo",
"atat_role": "default" "atat_role": "default",
}, },
"erica": { "erica": {
"id": "596fd001-bb1d-4adf-87d8-fa2312e882de", "id": "596fd001-bb1d-4adf-87d8-fa2312e882de",
"first_name": "Erica", "first_name": "Erica",
"last_name": "Eichner", "last_name": "Eichner",
"atat_role": "default" "atat_role": "default",
}, },
} }
class Dev(BaseHandler):
class Dev(BaseHandler):
def initialize(self, action, sessions, db_session): def initialize(self, action, sessions, db_session):
self.db_session = db_session self.db_session = db_session
self.action = action self.action = action

View File

@ -19,7 +19,7 @@ class RequestFinancialVerification(BaseHandler):
@tornado.gen.coroutine @tornado.gen.coroutine
def get(self, request_id=None): def get(self, request_id=None):
existing_request = self.get_existing_request(request_id) existing_request = self.get_existing_request(request_id)
form = FinancialForm(data=existing_request.body.get('financial_verification')) form = FinancialForm(data=existing_request.body.get("financial_verification"))
self.render( self.render(
"requests/financial_verification.html.to", "requests/financial_verification.html.to",
page=self.page, page=self.page,
@ -48,20 +48,16 @@ class RequestFinancialVerification(BaseHandler):
if form.validate(): if form.validate():
yield self.update_request(request_id, form.data) yield self.update_request(request_id, form.data)
valid = yield form.perform_extra_validation( valid = yield form.perform_extra_validation(
existing_request.body.get('financial_verification'), existing_request.body.get("financial_verification"),
self.pe_numbers_repo self.pe_numbers_repo,
) )
if valid: if valid:
self.redirect( self.redirect(
self.application.default_router.reverse_url("financial_verification_submitted") self.application.default_router.reverse_url(
"financial_verification_submitted"
)
) )
else: else:
self.render( self.render("requests/financial_verification.html.to", **rerender_args)
"requests/financial_verification.html.to",
**rerender_args
)
else: else:
self.render( self.render("requests/financial_verification.html.to", **rerender_args)
"requests/financial_verification.html.to",
**rerender_args
)

View File

@ -58,19 +58,15 @@ class RequestNew(BaseHandler):
where = "/requests" where = "/requests"
else: else:
where = self.application.default_router.reverse_url( where = self.application.default_router.reverse_url(
"request_form_update", jedi_flow.next_screen, jedi_flow.request_id "request_form_update",
jedi_flow.next_screen,
jedi_flow.request_id,
) )
self.redirect(where) self.redirect(where)
else: else:
self.render( self.render("requests/screen-%d.html.to" % int(screen), **rerender_args)
"requests/screen-%d.html.to" % int(screen),
**rerender_args
)
else: else:
self.render( self.render("requests/screen-%d.html.to" % int(screen), **rerender_args)
"requests/screen-%d.html.to" % int(screen),
**rerender_args
)
@tornado.web.authenticated @tornado.web.authenticated
@tornado.gen.coroutine @tornado.gen.coroutine
@ -82,7 +78,11 @@ class RequestNew(BaseHandler):
request = self.requests_repo.get(request_id) request = self.requests_repo.get(request_id)
jedi_flow = JEDIRequestFlow( jedi_flow = JEDIRequestFlow(
self.requests_repo, self.pe_numbers_repo, screen, request, request_id=request_id self.requests_repo,
self.pe_numbers_repo,
screen,
request,
request_id=request_id,
) )
self.render( self.render(
@ -94,7 +94,7 @@ class RequestNew(BaseHandler):
current=screen, current=screen,
next_screen=screen + 1, next_screen=screen + 1,
request_id=request_id, request_id=request_id,
can_submit=jedi_flow.can_submit can_submit=jedi_flow.can_submit,
) )
@ -140,13 +140,11 @@ class JEDIRequestFlow(object):
@tornado.gen.coroutine @tornado.gen.coroutine
def validate_warnings(self): def validate_warnings(self):
existing_request_data = ( existing_request_data = (
self.existing_request self.existing_request and self.existing_request.body.get(self.form_section)
and self.existing_request.body.get(self.form_section)
) or None ) or None
valid = yield self.form.perform_extra_validation( valid = yield self.form.perform_extra_validation(
existing_request_data, existing_request_data, self.pe_numbers_repo
self.pe_numbers_repo,
) )
return valid return valid
@ -174,7 +172,7 @@ class JEDIRequestFlow(object):
else: else:
data = self.request.body.get(self.form_section, {}) data = self.request.body.get(self.form_section, {})
return defaultdict(lambda: defaultdict(lambda: 'Input required'), data) return defaultdict(lambda: defaultdict(lambda: "Input required"), data)
@property @property
def can_submit(self): def can_submit(self):
@ -217,14 +215,12 @@ class JEDIRequestFlow(object):
"title": "Review & Submit", "title": "Review & Submit",
"section": "review_submit", "section": "review_submit",
"form": ReviewForm, "form": ReviewForm,
"show":True, "show": True,
}, },
] ]
def create_or_update_request(self): def create_or_update_request(self):
request_data = { request_data = {self.form_section: self.form.data}
self.form_section: self.form.data
}
if self.request_id: if self.request_id:
self.requests_repo.update(self.request_id, request_data) self.requests_repo.update(self.request_id, request_data)
else: else:

View File

@ -12,4 +12,6 @@ class Workspace(BaseHandler):
@tornado.gen.coroutine @tornado.gen.coroutine
def get(self, workspace_id): def get(self, workspace_id):
projects = self.projects_repo.get_many(workspace_id) projects = self.projects_repo.get_many(workspace_id)
self.render("workspace_projects.html.to", workspace_id=workspace_id, projects=projects) self.render(
"workspace_projects.html.to", workspace_id=workspace_id, projects=projects
)

View File

@ -12,4 +12,6 @@ class WorkspaceMembers(BaseHandler):
@tornado.gen.coroutine @tornado.gen.coroutine
def get(self, workspace_id): def get(self, workspace_id):
members = self.members_repo.get_many(workspace_id) members = self.members_repo.get_many(workspace_id)
self.render("workspace_members.html.to", workspace_id=workspace_id, members=members) self.render(
"workspace_members.html.to", workspace_id=workspace_id, members=members
)

View File

@ -2,6 +2,7 @@ from sqlalchemy import String, Column
from atst.models import Base from atst.models import Base
class PENumber(Base): class PENumber(Base):
__tablename__ = "pe_number" __tablename__ = "pe_number"
@ -10,4 +11,5 @@ class PENumber(Base):
def __repr__(self): def __repr__(self):
return "<PENumber(number='{}', description='{}')>".format( return "<PENumber(number='{}', description='{}')>".format(
self.number, self.description) self.number, self.description
)

View File

@ -8,15 +8,15 @@ from atst.models.types import Id
class Request(Base): class Request(Base):
__tablename__ = 'requests' __tablename__ = "requests"
id = Id() id = Id()
creator = Column(UUID(as_uuid=True)) creator = Column(UUID(as_uuid=True))
time_created = Column(DateTime(timezone=True), server_default=func.now()) time_created = Column(DateTime(timezone=True), server_default=func.now())
body = Column(JSONB) body = Column(JSONB)
status_events = relationship('RequestStatusEvent', status_events = relationship(
backref='request', "RequestStatusEvent", backref="request", order_by="RequestStatusEvent.sequence"
order_by='RequestStatusEvent.sequence') )
@property @property
def status(self): def status(self):

View File

@ -8,10 +8,14 @@ from atst.models.types import Id
class RequestStatusEvent(Base): class RequestStatusEvent(Base):
__tablename__ = 'request_status_events' __tablename__ = "request_status_events"
id = Id() id = Id()
new_status = Column(String()) new_status = Column(String())
time_created = Column(DateTime(timezone=True), server_default=func.now()) time_created = Column(DateTime(timezone=True), server_default=func.now())
request_id = Column(UUID(as_uuid=True), ForeignKey('requests.id', ondelete='CASCADE')) request_id = Column(
sequence = Column(BigInteger, Sequence('request_status_events_sequence_seq'), nullable=False) UUID(as_uuid=True), ForeignKey("requests.id", ondelete="CASCADE")
)
sequence = Column(
BigInteger, Sequence("request_status_events_sequence_seq"), nullable=False
)

View File

@ -2,6 +2,7 @@ from sqlalchemy import Column, Integer, String
from atst.models import Base from atst.models import Base
class TaskOrder(Base): class TaskOrder(Base):
__tablename__ = "task_order" __tablename__ = "task_order"

View File

@ -7,4 +7,5 @@ def Id():
return Column( return Column(
UUID(as_uuid=True), UUID(as_uuid=True),
primary_key=True, primary_key=True,
server_default=sqlalchemy.text("uuid_generate_v4()")) server_default=sqlalchemy.text("uuid_generate_v4()"),
)

View File

@ -5,6 +5,7 @@ from atst.domain.requests import Requests
bp = Blueprint("atst", __name__) bp = Blueprint("atst", __name__)
@bp.route("/") @bp.route("/")
def home(): def home():
return render_template("home.html") return render_template("home.html")

View File

@ -8,6 +8,7 @@ from atst.forms.financial import FinancialForm
requests_bp = Blueprint("requests", __name__) requests_bp = Blueprint("requests", __name__)
def map_request(user, request): def map_request(user, request):
time_created = pendulum.instance(request.time_created) time_created = pendulum.instance(request.time_created)
is_new = time_created.add(days=1) > pendulum.now() is_new = time_created.add(days=1) > pendulum.now()
@ -25,7 +26,10 @@ def map_request(user, request):
@requests_bp.route("/requests", methods=["GET"]) @requests_bp.route("/requests", methods=["GET"])
def requests_index(): def requests_index():
requests = [] requests = []
if "review_and_approve_jedi_workspace_request" in g.current_user["atat_permissions"]: if (
"review_and_approve_jedi_workspace_request"
in g.current_user["atat_permissions"]
):
requests = Requests.get_many() requests = Requests.get_many()
else: else:
requests = Requests.get_many(creator_id=g.current_user["id"]) requests = Requests.get_many(creator_id=g.current_user["id"])
@ -53,9 +57,10 @@ def requests_form_update(screen=1, request_id=None):
current=screen, current=screen,
next_screen=screen + 1, next_screen=screen + 1,
request_id=request_id, request_id=request_id,
can_submit=jedi_flow.can_submit can_submit=jedi_flow.can_submit,
) )
@requests_bp.route("/requests/new/<int:screen>/<string:request_id>", methods=["POST"]) @requests_bp.route("/requests/new/<int:screen>/<string:request_id>", methods=["POST"])
def requests_update(screen=1, request_id=None): def requests_update(screen=1, request_id=None):
screen = int(screen) screen = int(screen)
@ -87,28 +92,26 @@ def requests_update(screen=1, request_id=None):
where = "/requests" where = "/requests"
else: else:
where = url_for( where = url_for(
"requests.requests_form_update", screen=jedi_flow.next_screen, request_id=jedi_flow.request_id "requests.requests_form_update",
screen=jedi_flow.next_screen,
request_id=jedi_flow.request_id,
) )
return redirect(where) return redirect(where)
else: else:
return render_template( return render_template(
"requests/screen-%d.html" % int(screen), "requests/screen-%d.html" % int(screen), **rerender_args
**rerender_args
) )
else: else:
return render_template( return render_template("requests/screen-%d.html" % int(screen), **rerender_args)
"requests/screen-%d.html" % int(screen),
**rerender_args
)
@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(request_id) request = Requests.get(request_id)
form = FinancialForm(data=request.body.get('financial_verification')) form = FinancialForm(data=request.body.get("financial_verification"))
return render_template("requests/financial_verification.html", f=form, request_id=request_id) return render_template(
"requests/financial_verification.html", f=form, request_id=request_id
)
@requests_bp.route("/requests/verify/<string:request_id>", methods=["POST"]) @requests_bp.route("/requests/verify/<string:request_id>", methods=["POST"])

View File

@ -8,7 +8,6 @@ from atst.forms.poc import POCForm
from atst.forms.review import ReviewForm from atst.forms.review import ReviewForm
class JEDIRequestFlow(object): class JEDIRequestFlow(object):
def __init__( def __init__(
self, self,
@ -44,13 +43,10 @@ class JEDIRequestFlow(object):
def validate_warnings(self): def validate_warnings(self):
existing_request_data = ( existing_request_data = (
self.existing_request self.existing_request and self.existing_request.body.get(self.form_section)
and self.existing_request.body.get(self.form_section)
) or None ) or None
valid = self.form.perform_extra_validation( valid = self.form.perform_extra_validation(existing_request_data)
existing_request_data,
)
return valid return valid
@property @property
@ -77,7 +73,7 @@ class JEDIRequestFlow(object):
else: else:
data = self.request.body.get(self.form_section, {}) data = self.request.body.get(self.form_section, {})
return defaultdict(lambda: defaultdict(lambda: 'Input required'), data) return defaultdict(lambda: defaultdict(lambda: "Input required"), data)
@property @property
def can_submit(self): def can_submit(self):
@ -120,14 +116,12 @@ class JEDIRequestFlow(object):
"title": "Review & Submit", "title": "Review & Submit",
"section": "review_submit", "section": "review_submit",
"form": ReviewForm, "form": ReviewForm,
"show":True, "show": True,
}, },
] ]
def create_or_update_request(self): def create_or_update_request(self):
request_data = { request_data = {self.form_section: self.form.data}
self.form_section: self.form.data
}
if self.request_id: if self.request_id:
Requests.update(self.request_id, request_data) Requests.update(self.request_id, request_data)
else: else:

View File

@ -1,19 +1,26 @@
import os import os
import re import re
def navigationContext(self): def navigationContext(self):
return 'workspace' if re.match('\/workspaces\/[A-Za-z0-9]*', self.request.uri) else 'global' return (
"workspace"
if re.match("\/workspaces\/[A-Za-z0-9]*", self.request.uri)
else "global"
)
def dev(self): def dev(self):
return os.getenv("TORNADO_ENV", "dev") == "dev" return os.getenv("TORNADO_ENV", "dev") == "dev"
def matchesPath(self, href): def matchesPath(self, href):
return re.match('^'+href, self.request.uri) return re.match("^" + href, self.request.uri)
def modal(self, body): def modal(self, body):
return self.render_string( return self.render_string("components/modal.html.to", body=body)
"components/modal.html.to",
body=body)
def modalOpen(self): def modalOpen(self):
# For now, just check a dummy URL param # For now, just check a dummy URL param

View File

@ -1,41 +1,51 @@
from tornado.web import UIModule from tornado.web import UIModule
# from tornado.template import raw # from tornado.template import raw
import re import re
class Alert(UIModule): class Alert(UIModule):
def render(self, title, message=None, actions=None, level='info'): def render(self, title, message=None, actions=None, level="info"):
return self.render_string( return self.render_string(
"components/alert.html.to", "components/alert.html.to",
title=title, title=title,
message=message, message=message,
actions=actions, actions=actions,
level=level) level=level,
)
class TextInput(UIModule): class TextInput(UIModule):
def render(self, field, placeholder=''): def render(self, field, placeholder=""):
return self.render_string( return self.render_string(
"components/text_input.html.to", "components/text_input.html.to",
field=field, field=field,
label=re.sub('<[^<]+?>', '', str(field.label)), label=re.sub("<[^<]+?>", "", str(field.label)),
errors=field.errors, errors=field.errors,
placeholder=placeholder, placeholder=placeholder,
description=field.description) description=field.description,
)
class OptionsInput(UIModule): class OptionsInput(UIModule):
def render(self, field, inline=False): def render(self, field, inline=False):
return self.render_string( return self.render_string(
"components/options_input.html.to", "components/options_input.html.to",
field=field, field=field,
label=re.sub('<[^<]+?>', '', str(field.label)), label=re.sub("<[^<]+?>", "", str(field.label)),
errors=field.errors, errors=field.errors,
description=field.description, description=field.description,
inline=inline) inline=inline,
)
class Icon(UIModule): class Icon(UIModule):
def render(self, name, classes=''): def render(self, name, classes=""):
with open('static/icons/%s.svg' % name) as svg: with open("static/icons/%s.svg" % name) as svg:
return self.render_string( return self.render_string(
"components/icon.html.to", svg=svg.read(), name=name, classes=classes) "components/icon.html.to", svg=svg.read(), name=name, classes=classes
)
class SidenavItem(UIModule): class SidenavItem(UIModule):
def render(self, label, href, active=False, icon=None, subnav=None): def render(self, label, href, active=False, icon=None, subnav=None):
@ -45,7 +55,9 @@ class SidenavItem(UIModule):
href=href, href=href,
active=active, active=active,
icon=icon, icon=icon,
subnav=subnav) subnav=subnav,
)
class EmptyState(UIModule): class EmptyState(UIModule):
def render(self, message, actionLabel, actionHref, icon=None): def render(self, message, actionLabel, actionHref, icon=None):
@ -54,4 +66,5 @@ class EmptyState(UIModule):
message=message, message=message,
actionLabel=actionLabel, actionLabel=actionLabel,
actionHref=actionHref, actionHref=actionHref,
icon=icon) icon=icon,
)