mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-11 02:23:19 -04:00
notify-api-412 use black to enforce python coding style
This commit is contained in:
@@ -10,21 +10,20 @@ from app.utils.user import user_is_gov_user, user_is_logged_in
|
||||
|
||||
|
||||
def _create_service(service_name, organization_type, email_from, form):
|
||||
|
||||
try:
|
||||
service_id = service_api_client.create_service(
|
||||
service_name=service_name,
|
||||
organization_type=organization_type,
|
||||
message_limit=current_app.config['DEFAULT_SERVICE_LIMIT'],
|
||||
message_limit=current_app.config["DEFAULT_SERVICE_LIMIT"],
|
||||
restricted=True,
|
||||
user_id=session['user_id'],
|
||||
user_id=session["user_id"],
|
||||
email_from=email_from,
|
||||
)
|
||||
session['service_id'] = service_id
|
||||
session["service_id"] = service_id
|
||||
|
||||
return service_id, None
|
||||
except HTTPError as e:
|
||||
if e.status_code == 400 and e.message['name']:
|
||||
if e.status_code == 400 and e.message["name"]:
|
||||
form.name.errors.append("This service name is already in use")
|
||||
return None, e
|
||||
else:
|
||||
@@ -33,15 +32,15 @@ def _create_service(service_name, organization_type, email_from, form):
|
||||
|
||||
def _create_example_template(service_id):
|
||||
example_sms_template = service_api_client.create_service_template(
|
||||
'Example text message template',
|
||||
'sms',
|
||||
'Hi, I’m trying out Notify.gov. Today is ((day of week)) and my favorite color is ((color)).',
|
||||
"Example text message template",
|
||||
"sms",
|
||||
"Hi, I’m trying out Notify.gov. Today is ((day of week)) and my favorite color is ((color)).",
|
||||
service_id,
|
||||
)
|
||||
return example_sms_template
|
||||
|
||||
|
||||
@main.route("/add-service", methods=['GET', 'POST'])
|
||||
@main.route("/add-service", methods=["GET", "POST"])
|
||||
@user_is_logged_in
|
||||
@user_is_gov_user
|
||||
def add_service():
|
||||
@@ -64,33 +63,42 @@ def add_service():
|
||||
)
|
||||
if error:
|
||||
return _render_add_service_page(form, default_organization_type)
|
||||
if len(service_api_client.get_active_services({'user_id': session['user_id']}).get('data', [])) > 1:
|
||||
return redirect(url_for('main.service_dashboard', service_id=service_id))
|
||||
if (
|
||||
len(
|
||||
service_api_client.get_active_services(
|
||||
{"user_id": session["user_id"]}
|
||||
).get("data", [])
|
||||
)
|
||||
> 1
|
||||
):
|
||||
return redirect(url_for("main.service_dashboard", service_id=service_id))
|
||||
|
||||
example_sms_template = _create_example_template(service_id)
|
||||
|
||||
return redirect(url_for(
|
||||
'main.begin_tour',
|
||||
service_id=service_id,
|
||||
template_id=example_sms_template['data']['id']
|
||||
))
|
||||
return redirect(
|
||||
url_for(
|
||||
"main.begin_tour",
|
||||
service_id=service_id,
|
||||
template_id=example_sms_template["data"]["id"],
|
||||
)
|
||||
)
|
||||
else:
|
||||
return _render_add_service_page(form, default_organization_type)
|
||||
|
||||
|
||||
def _render_add_service_page(form, default_organization_type):
|
||||
heading = 'About your service'
|
||||
heading = "About your service"
|
||||
|
||||
if default_organization_type == 'local':
|
||||
if default_organization_type == "local":
|
||||
return render_template(
|
||||
'views/add-service-local.html',
|
||||
"views/add-service-local.html",
|
||||
form=form,
|
||||
heading=heading,
|
||||
default_organization_type=default_organization_type,
|
||||
)
|
||||
|
||||
return render_template(
|
||||
'views/add-service.html',
|
||||
"views/add-service.html",
|
||||
form=form,
|
||||
heading=heading,
|
||||
default_organization_type=default_organization_type,
|
||||
|
||||
Reference in New Issue
Block a user