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

Show profile actions

parent 941e3e6e
No related branches found
No related tags found
No related merge requests found
{% extends "base.html" %}
{% block title %}{{ profile.username }}{% endblock %}
{% block subtitle %}{{ label.lower() }}{% endblock %}
{% block content %}
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-body">
{{ result | safe }}
</div>
</div>
</div>
{% endblock %}
{% block actions %}
<a href="{{ url_for("profile.details", profile_uuid=profile.uuid) }}" class="btn btn-info">{% trans %}Show profile{% endtrans %}</a>
{% endblock %}
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
{% block content %} {% block content %}
<div class="row"> <div class="row">
<div class="col-xs-12"> <div class="col-md-6 col-xs-12">
<div class="box"> <div class="box">
<div class="box-body"> <div class="box-body">
<dl class="dl-horizontal"> <dl class="dl-horizontal">
...@@ -25,6 +25,23 @@ ...@@ -25,6 +25,23 @@
<dd>{{ profile.created_at }}</dd> <dd>{{ profile.created_at }}</dd>
</dl> </dl>
</div> </div>
</div>
</div>
<div class="col-md-6 col-xs-12">
<div class="box">
<div class="box-header">
<h4>{% trans %}Advanced actions{% endtrans %}</h4>
</div>
<div class="box-body">
<dl class="dl-horizontal">
{% for action, (label, for_profile, _, function) in profile.service.application.actions.items() %}
{% if for_profile %}
<dt><a href="{{ url_for(".action", profile_uuid=profile.uuid, action=action) }}">{{ label }}</a></dt>
<dd>{{ function.__doc__ }}</dd>
{% endif %}
{% endfor %}
</dl>
</div>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -164,6 +164,19 @@ def details(profile_uuid): ...@@ -164,6 +164,19 @@ def details(profile_uuid):
return flask.render_template("profile_details.html", profile=profile) return flask.render_template("profile_details.html", profile=profile)
@blueprint.route("/action/<profile_uuid>/<action>", methods=["GET", "POST"])
@security.admin_required()
def action(profile_uuid, action):
profile = models.Profile.query.get(profile_uuid) or flask.abort(404)
app = profile.service.application or flask.abort(404)
label, for_profile, quick, function = app.actions.get(action) or flask.abort(404)
if not for_profile:
flask.abort(404)
result = getattr(app, action)(profile)
return flask.render_template("profile_action.html",
label=label, profile=profile, result=result)
@blueprint.route("/transition/<profile_uuid>/<transition>", methods=["GET", "POST"]) @blueprint.route("/transition/<profile_uuid>/<transition>", methods=["GET", "POST"])
@security.confirmation_required("change the profile status") @security.confirmation_required("change the profile status")
@security.admin_required() @security.admin_required()
......
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