mirror of
https://github.com/pretix/pretix.git
synced 2026-05-07 15:34:02 +00:00
- [x] Data model - [x] UI - [x] Fire hooks - [x] Unit tests - [x] Display logs - [x] API to modify hooks - [x] Documentation - [x] More hooks!
This commit is contained in:
@@ -46,6 +46,13 @@
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if 'can_change_organizer_settings' in request.orgapermset %}
|
||||
<li {% if "organizer.webhook" in url_name %}class="active"{% endif %}>
|
||||
<a href="{% url "control:organizer.webhooks" organizer=organizer.slug %}">
|
||||
{% trans "Webhooks" %}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% for nav in nav_organizer %}
|
||||
<li {% if nav.active %}class="active"{% endif %}>
|
||||
<a href="{{ nav.url }}">
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
{% extends "pretixcontrol/organizers/base.html" %}
|
||||
{% load i18n %}
|
||||
{% load bootstrap3 %}
|
||||
{% block inner %}
|
||||
{% if webhook %}
|
||||
<legend>{% trans "Modify webhook" %}</legend>
|
||||
{% else %}
|
||||
<legend>{% trans "Create a new webhook" %}</legend>
|
||||
{% endif %}
|
||||
<form class="form-horizontal" action="" method="post">
|
||||
{% csrf_token %}
|
||||
{% bootstrap_form_errors form %}
|
||||
{% bootstrap_field form.target_url layout="control" %}
|
||||
{% bootstrap_field form.enabled layout="control" %}
|
||||
{% bootstrap_field form.events layout="control" %}
|
||||
{% bootstrap_field form.all_events layout="control" %}
|
||||
{% bootstrap_field form.limit_events layout="control" %}
|
||||
<div class="form-group submit-group">
|
||||
<button type="submit" class="btn btn-primary btn-save">
|
||||
{% trans "Save" %}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,67 @@
|
||||
{% extends "pretixcontrol/organizers/base.html" %}
|
||||
{% load i18n %}
|
||||
{% load bootstrap3 %}
|
||||
{% block inner %}
|
||||
<legend>{% blocktrans with url=webhook.target_url %}Logs for webhook {{ url }}{% endblocktrans %}</legend>
|
||||
<p>
|
||||
{% trans "This page shows all calls to your webhook in the past 30 days." %}
|
||||
</p>
|
||||
{% for c in calls %}
|
||||
<details class="panel panel-default">
|
||||
<summary class="panel-heading">
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-sm-12 col-xs-12">
|
||||
{% if c.is_retry %}
|
||||
<span class="fa fa-repeat fa-fw" data-toggle="tooltip" title="{% trans "This webhook was retried since it previously failed." %}"></span>
|
||||
{% else %}
|
||||
<span class="fa fa-clock-o fa-fw"></span>
|
||||
{% endif %}
|
||||
{{ c.datetime|date:"SHORT_DATETIME_FORMAT" }}
|
||||
</div>
|
||||
<div class="col-md-4 col-sm-12 col-xs-12">
|
||||
<span class="fa fa-tag fa-fw"></span>
|
||||
{{ c.action_type }}
|
||||
</div>
|
||||
<div class="col-md-2 col-sm-2 col-xs-4">
|
||||
<span class="fa fa-hourglass fa-fw"></span>
|
||||
{{ c.execution_time|floatformat:2 }}s
|
||||
</div>
|
||||
<div class="col-md-2 col-xs-8 text-right">
|
||||
{% if c.success %}
|
||||
<span class="label label-success">
|
||||
<span class="fa fa-check-circle fa-fw"></span>
|
||||
{{ c.return_code }}
|
||||
</span>
|
||||
{% else %}
|
||||
{% if c.return_code %}
|
||||
<span class="label label-danger">
|
||||
<span class="fa fa-warning fa-fw"></span>
|
||||
{{ c.return_code }}
|
||||
</span>
|
||||
{% else %}
|
||||
<span class="label label-danger">
|
||||
<span class="fa fa-warning fa-fw"></span>
|
||||
{% trans "Failed" %}
|
||||
</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</summary>
|
||||
<div id="{{ c.pk }}">
|
||||
|
||||
<div class="panel-body">
|
||||
<strong>{% trans "Request URL" %}</strong>
|
||||
<pre><code>POST {{ c.target_url }}</code></pre>
|
||||
<strong>{% trans "Request POST body" %}</strong>
|
||||
<pre><code>{{ c.payload }}</code></pre>
|
||||
<strong>{% trans "Response body" %}</strong>
|
||||
<pre><code>{{ c.response_body }}</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
{% empty %}
|
||||
<div class="alert-info">{% trans "This webhook did not receive any events in the last 30 days." %}</div>
|
||||
{% endfor %}
|
||||
{% include "pretixcontrol/pagination.html" %}
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,78 @@
|
||||
{% extends "pretixcontrol/organizers/base.html" %}
|
||||
{% load i18n %}
|
||||
{% load bootstrap3 %}
|
||||
{% block inner %}
|
||||
<legend>
|
||||
{% trans "Webhooks" %}
|
||||
</legend>
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
This menu allows you to create webhooks to connect pretix to other online services.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
{% if webhooks|length == 0 %}
|
||||
<div class="empty-collection">
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
You haven't created any webhooks yet.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
|
||||
<a href="{% url "control:organizer.webhook.add" organizer=request.organizer.slug %}"
|
||||
class="btn btn-primary btn-lg"><i class="fa fa-plus"></i> {% trans "Create webhook" %}</a>
|
||||
</div>
|
||||
{% else %}
|
||||
<p>
|
||||
<a href="{% url "control:organizer.webhook.add" organizer=request.organizer.slug %}"
|
||||
class="btn btn-default"><i class="fa fa-plus"></i> {% trans "Create webhook" %}</a>
|
||||
</p>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-condensed table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{% trans "Target URL" %}</th>
|
||||
<th>{% trans "Events" %}</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for w in webhooks %}
|
||||
<tr>
|
||||
<td>
|
||||
{% if not w.enabled %}<del>{% endif %}
|
||||
{{ w.target_url }}
|
||||
{% if not w.enabled %}</del>{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if w.all_events %}
|
||||
{% trans "All" %}
|
||||
{% else %}
|
||||
<ul>
|
||||
{% for e in w.limit_events.all %}
|
||||
<li>
|
||||
<a href="{% url "control:event.index" organizer=request.organizer.slug event=e.slug %}">
|
||||
{{ e }}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<a href="{% url "control:organizer.webhook.edit" organizer=request.organizer.slug webhook=w.id %}"
|
||||
class="btn btn-default btn-sm" data-toggle="tooltip" title="{% trans "Edit" %}">
|
||||
<i class="fa fa-edit"></i>
|
||||
</a>
|
||||
<a href="{% url "control:organizer.webhook.logs" organizer=request.organizer.slug webhook=w.id %}"
|
||||
class="btn btn-default btn-sm" data-toggle="tooltip" title="{% trans "Logs" %}">
|
||||
<i class="fa fa-list"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% include "pretixcontrol/pagination.html" %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user