Skip to content
Snippets Groups Projects
Commit d8f81dd5 authored by kaiyou's avatar kaiyou
Browse files

Support switching application type

parent 71c96f19
No related branches found
No related tags found
No related merge requests found
{% 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__ }}&nbsp;</h5>
......
......@@ -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
......@@ -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 %}
......@@ -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 %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment