diff --git a/hiboo/application/templates/application_pick.html b/hiboo/application/templates/application_pick.html index 2e5dc6754c60ef6192119a17c01a1efe6dfca968..8e87f3b1be8b717c7c7c5830c5b6040b5d371270 100644 --- a/hiboo/application/templates/application_pick.html +++ b/hiboo/application/templates/application_pick.html @@ -1,7 +1,6 @@ {% extends "base.html" %} -{% block title %}{% trans %}Create a service{% endtrans %}{% endblock %} -{% block subtitle %}{% trans %}pick an application{% endtrans %}{% endblock %} +{% block title %}{% trans %}Select application type{% endtrans %}{% endblock %} {% block content %} <div class="row"> @@ -9,8 +8,8 @@ <div class="col-md-4 col-s-6 col-xs-12"> <div class="box box-widget widget-user-2"> <div class="widget-user-header bg-{{ macros.colors[loop.index0 % 7] }}"> - <a href="{{ url_for(route, application_id=application_id) }}" style="opacity: 0.8" class="btn btn-lg bg-gray text-black pull-right"> - {% trans %}Create{% endtrans %} + <a href="{{ url_for(route, application_id=application_id, **kwargs) }}" style="opacity: 0.8" class="btn btn-lg bg-gray text-black pull-right"> + {% trans %}Select{% endtrans %} </a> <h3 class="widget-header-username">{{ application.name }}</h3> <h5 class="widget-header-desc">{{ application.__doc__ }} </h5> diff --git a/hiboo/service/admin.py b/hiboo/service/admin.py index e7219517974bb5f84a0bc296311edcf35acf2758..bd41a146c48ced2b6ba22129c9ee219a80a4d948 100644 --- a/hiboo/service/admin.py +++ b/hiboo/service/admin.py @@ -14,15 +14,19 @@ def list(): @blueprint.route("/create") +@security.admin_required() +def create_select(): + return flask.render_template( + "application_pick.html", + applications=application.registry, + route="service.create", + kwargs={} + ) + + @blueprint.route("/create/<application_id>", methods=["GET", "POST"]) @security.admin_required() -def create(application_id=None): - if application_id is None: - return flask.render_template( - "application_pick.html", - applications=application.registry, - route="service.create" - ) +def create(application_id): app = application.registry.get(application_id) or flask.abort(404) form = app.Form() if form.validate_on_submit(): @@ -72,3 +76,25 @@ def delete(service_uuid): models.db.session.delete(service) models.db.session.commit() return flask.redirect(flask.url_for(".list")) + + +@blueprint.route("/setapp/<service_uuid>") +@security.admin_required() +def setapp_select(service_uuid): + return flask.render_template( + "application_pick.html", + applications=application.registry, + route="service.setapp", + kwargs={"service_uuid": service_uuid} + ) + + +@blueprint.route("/setapp/<service_uuid>/<application_id>", methods=["GET", "POST"]) +@security.admin_required() +@security.confirmation_required("change the service application template") +def setapp(service_uuid, application_id): + service = models.Service.query.get(service_uuid) or flask.abort(404) + app = application.registry.get(application_id) or flask.abort(404) + service.application_id = application_id + models.db.session.commit() + return flask.redirect(flask.url_for(".edit", service_uuid=service_uuid)) \ No newline at end of file diff --git a/hiboo/service/templates/service_details.html b/hiboo/service/templates/service_details.html index 3a9963dcb4b5d2f6a4f5578ac2e4d63f3bf5fc1c..f54b44af988452b5a52a7ee116321f3d8a6c4b1b 100644 --- a/hiboo/service/templates/service_details.html +++ b/hiboo/service/templates/service_details.html @@ -43,6 +43,7 @@ {% block actions %} <a href="{{ url_for("profile.list_for_service", service_uuid=service.uuid) }}" class="btn btn-primary">{% trans %}View profiles{% endtrans %}</a> +<a href="{{ url_for(".setapp_select", service_uuid=service.uuid) }}" class="btn btn-primary">{% trans %}Change application{% endtrans %}</a> <a href="{{ url_for(".edit", service_uuid=service.uuid) }}" class="btn btn-primary">{% trans %}Edit this service{% endtrans %}</a> <a href="{{ url_for(".delete", service_uuid=service.uuid) }}" class="btn btn-danger">{% trans %}Delete this service{% endtrans %}</a> {% endblock %} diff --git a/hiboo/service/templates/service_list.html b/hiboo/service/templates/service_list.html index d6bc62ba15647fcbf341a2c5765968d0681d6eb4..615ada8f85ad68c64e6abf25be14b4291ddd09e6 100644 --- a/hiboo/service/templates/service_list.html +++ b/hiboo/service/templates/service_list.html @@ -38,5 +38,5 @@ {% endblock %} {% block actions %} -<a href="{{ url_for(".create") }}" class="btn btn-success">{% trans %}Create a service{% endtrans %}</a> +<a href="{{ url_for(".create_select") }}" class="btn btn-success">{% trans %}Create a service{% endtrans %}</a> {% endblock %}