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(
__name__,
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)
@ -44,23 +44,25 @@ def make_app(config):
def make_flask_callbacks(app):
@app.before_request
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.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.current_user = {
"id": "cce17030-4109-4719-b958-ed109dbb87c8",
"first_name": "Amanda",
"last_name": "Adamson",
"atat_role": "default",
"atat_permissions": []
"atat_permissions": [],
}
# TODO: Make me a macro
def modal(self, body):
return self.render_string(
"components/modal.html.to",
body=body)
return self.render_string("components/modal.html.to", body=body)
# def make_app(config, deps, **kwargs):
@ -211,6 +213,7 @@ def make_deps(config):
),
}
def map_config(config):
return {
"ENV": config["default"]["ENVIRONMENT"],
@ -218,9 +221,10 @@ def map_config(config):
"PORT": int(config["default"]["PORT"]),
"SQLALCHEMY_DATABASE_URI": config["default"]["DATABASE_URI"],
"SQLALCHEMY_TRACK_MODIFICATIONS": False,
**config["default"]
**config["default"],
}
def make_config():
BASE_CONFIG_FILENAME = os.path.join(os.path.dirname(__file__), "../config/base.ini")
ENV_CONFIG_FILENAME = os.path.join(

View File

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

View File

@ -102,7 +102,9 @@ class Requests(object):
request.body = deep_merge(request_delta, request.body)
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,
# since it doesn't track dictionary mutations by default.

View File

@ -5,13 +5,14 @@ from .exceptions import NotFoundError
class TaskOrders(object):
def __init__(self, db_session):
self.db_session = db_session
def get(self, order_number):
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:
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=",
"pay_dodaac": None,
"pco_mod": "02",
"amount": 2000000
"amount": 2000000,
}
else:
return None

View File

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

View File

@ -12,13 +12,17 @@ from .fields import NewlineListField
from .forms import ValidatedForm
PE_REGEX = re.compile(r"""
PE_REGEX = re.compile(
r"""
(0?\d) # program identifier
(0?\d) # category
(\d) # activity
(\d+) # sponsor element
(.+) # service
""", re.X)
""",
re.X,
)
def suggest_pe_id(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. {}"
"If you have double checked it you can submit anyway. "
"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)
return False
@ -53,10 +57,9 @@ def validate_pe_id(field, existing_request, pe_numbers_repo):
class FinancialForm(ValidatedForm):
def perform_extra_validation(self, existing_request, pe_numbers_repo):
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)
return valid
@ -68,9 +71,7 @@ class FinancialForm(ValidatedForm):
"Unique Item Identifier (UII)s related to your application(s) if you already have them."
)
pe_id = StringField(
"Program Element (PE) Number related to your request"
)
pe_id = StringField("Program Element (PE) Number related to your request")
treasury_code = StringField("Program Treasury Code")
@ -116,11 +117,13 @@ class FinancialForm(ValidatedForm):
)
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(
"<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(

View File

@ -4,7 +4,6 @@ from flask_wtf import FlaskForm
class ValidatedForm(FlaskForm):
def perform_extra_validation(self, *args, **kwargs):
"""Performs any applicable extra validation. Must
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):
fname_request = StringField(
"First Name",
validators=[Required(), Alphabet()]
)
fname_request = StringField("First Name", validators=[Required(), Alphabet()])
lname_request = StringField(
"Last Name",
validators=[Required(), Alphabet()]
)
lname_request = StringField("Last Name", validators=[Required(), Alphabet()])
email_request = EmailField(
"Email Address",
validators=[Required(), Email()]
)
email_request = EmailField("Email Address", validators=[Required(), Email()])
phone_number = TelField(
"Phone Number",
validators=[Required(), PhoneNumber()]
)
phone_number = TelField("Phone Number", validators=[Required(), PhoneNumber()])
service_branch = StringField(
"Service Branch or Agency",
validators=[Required()]
)
service_branch = StringField("Service Branch or Agency", validators=[Required()])
citizenship = RadioField(
choices=[

View File

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

View File

@ -14,18 +14,21 @@ class RequestForm(ValidatedForm):
"DoD Component",
description="Identify the DoD component that is requesting access to the JEDI Cloud",
choices=[
("null","Select an option"),
("us_air_force","US Air Force"),
("us_army","US Army"),
("us_navy","US Navy"),
("us_marine_corps","US Marine Corps"),
("joint_chiefs_of_staff","Joint Chiefs of Staff")],
("null", "Select an option"),
("us_air_force", "US Air Force"),
("us_army", "US Army"),
("us_navy", "US Navy"),
("us_marine_corps", "US Marine Corps"),
("joint_chiefs_of_staff", "Joint Chiefs of Staff"),
],
)
jedi_usage = TextAreaField(
"JEDI Usage",
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
@ -41,7 +44,7 @@ class RequestForm(ValidatedForm):
rationalization_software_systems = RadioField(
"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(
@ -52,40 +55,43 @@ class RequestForm(ValidatedForm):
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:",
choices=[
("in_house_staff","In-house staff"),
("contractor","Contractor"),
("other_dod_organization","Other DoD organization")],
("in_house_staff", "In-house staff"),
("contractor", "Contractor"),
("other_dod_organization", "Other DoD organization"),
],
)
engineering_assessment = RadioField(
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(
description="How much data is being transferred to the cloud?",
choices=[
("null","Select an option"),
("less_than_100gb","Less than 100GB"),
("100gb-500gb","100GB-500GB"),
("500gb-1tb","500GB-1TB"),
("1tb-50tb","1TB-50TB"),
("50tb-100tb","50TB-100TB"),
("100tb-500tb","100TB-500TB"),
("500tb-1pb","500TB-1PB"),
("1pb-5pb","1PB-5PB"),
("5pb-10pb","5PB-10PB"),
("above_10pb","Above 10PB")],
("null", "Select an option"),
("less_than_100gb", "Less than 100GB"),
("100gb-500gb", "100GB-500GB"),
("500gb-1tb", "500GB-1TB"),
("1tb-50tb", "1TB-50TB"),
("50tb-100tb", "50TB-100TB"),
("100tb-500tb", "100TB-500TB"),
("500tb-1pb", "500TB-1PB"),
("1pb-5pb", "1PB-5PB"),
("5pb-10pb", "5PB-10PB"),
("above_10pb", "Above 10PB"),
],
)
expected_completion_date = SelectField(
description="When do you expect to complete your migration to the JEDI Cloud?",
choices=[
("null","Select an option"),
("less_than_1_month","Less than 1 month"),
("1_to_3_months","1-3 months"),
("3_to_6_months","3-6 months"),
("above_12_months","Above 12 months")],
("null", "Select an option"),
("less_than_1_month", "Less than 1 month"),
("1_to_3_months", "1-3 months"),
("3_to_6_months", "3-6 months"),
("above_12_months", "Above 12 months"),
],
)
cloud_native = RadioField(
@ -96,7 +102,7 @@ class RequestForm(ValidatedForm):
# Details of Use: Financial Usage
estimated_monthly_spend = IntegerField(
"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(
@ -105,17 +111,13 @@ class RequestForm(ValidatedForm):
)
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(
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(
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):
def get_template_namespace(self):
ns = super(BaseHandler, self).get_template_namespace()
helpers["config"] = self.application.config

View File

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

View File

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

View File

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

View File

@ -12,4 +12,6 @@ class Workspace(BaseHandler):
@tornado.gen.coroutine
def get(self, 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
def get(self, 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
class PENumber(Base):
__tablename__ = "pe_number"
@ -10,4 +11,5 @@ class PENumber(Base):
def __repr__(self):
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):
__tablename__ = 'requests'
__tablename__ = "requests"
id = Id()
creator = Column(UUID(as_uuid=True))
time_created = Column(DateTime(timezone=True), server_default=func.now())
body = Column(JSONB)
status_events = relationship('RequestStatusEvent',
backref='request',
order_by='RequestStatusEvent.sequence')
status_events = relationship(
"RequestStatusEvent", backref="request", order_by="RequestStatusEvent.sequence"
)
@property
def status(self):

View File

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

View File

@ -7,4 +7,5 @@ def Id():
return Column(
UUID(as_uuid=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.route("/")
def home():
return render_template("home.html")

View File

@ -8,6 +8,7 @@ from atst.forms.financial import FinancialForm
requests_bp = Blueprint("requests", __name__)
def map_request(user, request):
time_created = pendulum.instance(request.time_created)
is_new = time_created.add(days=1) > pendulum.now()
@ -25,7 +26,10 @@ def map_request(user, request):
@requests_bp.route("/requests", methods=["GET"])
def requests_index():
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()
else:
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,
next_screen=screen + 1,
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"])
def requests_update(screen=1, request_id=None):
screen = int(screen)
@ -87,28 +92,26 @@ def requests_update(screen=1, request_id=None):
where = "/requests"
else:
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)
else:
return render_template(
"requests/screen-%d.html" % int(screen),
**rerender_args
"requests/screen-%d.html" % int(screen), **rerender_args
)
else:
return render_template(
"requests/screen-%d.html" % int(screen),
**rerender_args
)
return render_template("requests/screen-%d.html" % int(screen), **rerender_args)
@requests_bp.route("/requests/verify/<string:request_id>", methods=["GET"])
def financial_verification(request_id=None):
request = Requests.get(request_id)
form = FinancialForm(data=request.body.get('financial_verification'))
return render_template("requests/financial_verification.html", f=form, request_id=request_id)
form = FinancialForm(data=request.body.get("financial_verification"))
return render_template(
"requests/financial_verification.html", f=form, request_id=request_id
)
@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
class JEDIRequestFlow(object):
def __init__(
self,
@ -44,13 +43,10 @@ class JEDIRequestFlow(object):
def validate_warnings(self):
existing_request_data = (
self.existing_request
and self.existing_request.body.get(self.form_section)
self.existing_request and self.existing_request.body.get(self.form_section)
) or None
valid = self.form.perform_extra_validation(
existing_request_data,
)
valid = self.form.perform_extra_validation(existing_request_data)
return valid
@property
@ -77,7 +73,7 @@ class JEDIRequestFlow(object):
else:
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
def can_submit(self):
@ -120,14 +116,12 @@ class JEDIRequestFlow(object):
"title": "Review & Submit",
"section": "review_submit",
"form": ReviewForm,
"show":True,
"show": True,
},
]
def create_or_update_request(self):
request_data = {
self.form_section: self.form.data
}
request_data = {self.form_section: self.form.data}
if self.request_id:
Requests.update(self.request_id, request_data)
else:

View File

@ -1,19 +1,26 @@
import os
import re
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):
return os.getenv("TORNADO_ENV", "dev") == "dev"
def matchesPath(self, href):
return re.match('^'+href, self.request.uri)
return re.match("^" + href, self.request.uri)
def modal(self, body):
return self.render_string(
"components/modal.html.to",
body=body)
return self.render_string("components/modal.html.to", body=body)
def modalOpen(self):
# For now, just check a dummy URL param

View File

@ -1,57 +1,70 @@
from tornado.web import UIModule
# from tornado.template import raw
import re
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(
"components/alert.html.to",
title=title,
message=message,
actions=actions,
level=level)
"components/alert.html.to",
title=title,
message=message,
actions=actions,
level=level,
)
class TextInput(UIModule):
def render(self, field, placeholder=''):
def render(self, field, placeholder=""):
return self.render_string(
"components/text_input.html.to",
field=field,
label=re.sub('<[^<]+?>', '', str(field.label)),
errors=field.errors,
placeholder=placeholder,
description=field.description)
"components/text_input.html.to",
field=field,
label=re.sub("<[^<]+?>", "", str(field.label)),
errors=field.errors,
placeholder=placeholder,
description=field.description,
)
class OptionsInput(UIModule):
def render(self, field, inline=False):
return self.render_string(
"components/options_input.html.to",
field=field,
label=re.sub('<[^<]+?>', '', str(field.label)),
errors=field.errors,
description=field.description,
inline=inline)
"components/options_input.html.to",
field=field,
label=re.sub("<[^<]+?>", "", str(field.label)),
errors=field.errors,
description=field.description,
inline=inline,
)
class Icon(UIModule):
def render(self, name, classes=''):
with open('static/icons/%s.svg' % name) as svg:
def render(self, name, classes=""):
with open("static/icons/%s.svg" % name) as svg:
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):
def render(self, label, href, active=False, icon=None, subnav=None):
return self.render_string(
"navigation/_sidenav_item.html.to",
label=label,
href=href,
active=active,
icon=icon,
subnav=subnav)
"navigation/_sidenav_item.html.to",
label=label,
href=href,
active=active,
icon=icon,
subnav=subnav,
)
class EmptyState(UIModule):
def render(self, message, actionLabel, actionHref, icon=None):
return self.render_string(
"components/empty_state.html.to",
message=message,
actionLabel=actionLabel,
actionHref=actionHref,
icon=icon)
"components/empty_state.html.to",
message=message,
actionLabel=actionLabel,
actionHref=actionHref,
icon=icon,
)