2021-03-02 09:55:07 +00:00
|
|
|
import uuid
|
|
|
|
|
from contextlib import suppress
|
|
|
|
|
|
|
|
|
|
from flask import redirect, render_template, url_for
|
2019-08-13 16:25:26 +01:00
|
|
|
|
|
|
|
|
from app import service_api_client
|
|
|
|
|
from app.main import main
|
|
|
|
|
from app.main.forms import SearchByNameForm
|
2021-06-09 13:19:05 +01:00
|
|
|
from app.utils.user import user_is_platform_admin
|
2019-08-13 16:25:26 +01:00
|
|
|
|
|
|
|
|
|
2023-08-25 09:12:23 -07:00
|
|
|
@main.route("/find-services-by-name", methods=["GET", "POST"])
|
2019-08-13 16:25:26 +01:00
|
|
|
@user_is_platform_admin
|
|
|
|
|
def find_services_by_name():
|
|
|
|
|
form = SearchByNameForm()
|
|
|
|
|
services_found = None
|
|
|
|
|
if form.validate_on_submit():
|
2021-03-02 09:55:07 +00:00
|
|
|
with suppress(ValueError):
|
2023-08-25 09:12:23 -07:00
|
|
|
return redirect(
|
|
|
|
|
url_for(
|
|
|
|
|
"main.service_dashboard", service_id=uuid.UUID(form.search.data)
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
services_found = service_api_client.find_services_by_name(
|
|
|
|
|
service_name=form.search.data
|
|
|
|
|
)["data"]
|
2019-08-13 16:25:26 +01:00
|
|
|
return render_template(
|
2023-08-25 09:12:23 -07:00
|
|
|
"views/find-services/find-services-by-name.html",
|
2019-08-13 16:25:26 +01:00
|
|
|
form=form,
|
2023-08-25 09:12:23 -07:00
|
|
|
services_found=services_found,
|
2019-08-15 12:41:46 +01:00
|
|
|
)
|