New implementation of sales channels (#4111)

Co-authored-by: Martin Gross <gross@rami.io>
This commit is contained in:
Raphael Michel
2024-06-30 19:24:30 +02:00
committed by GitHub
parent 95511b0330
commit 4fb5c6bef0
174 changed files with 2902 additions and 616 deletions

View File

@@ -0,0 +1,27 @@
{% extends "pretixcontrol/organizers/base.html" %}
{% load i18n %}
{% load formset_tags %}
{% load bootstrap3 %}
{% block inner %}
<h1>{% trans "Add sales channel" %}</h1>
<form class="form-horizontal" action="" method="post">
{% csrf_token %}
{% bootstrap_form_errors form layout="control" %}
{% bootstrap_field form.label layout="control" %}
<div class="form-group">
<label class="col-md-3 control-label" for="id_identifier">{% trans "Channel type" %}</label>
<div class="col-md-9">
<input type="text" value="{{ type.verbose_name }}" class="form-control" disabled>
</div>
</div>
{% bootstrap_field form.identifier addon_before=identifier_prefix layout="control" %}
<div class="form-group submit-group">
<button type="submit" class="btn btn-primary btn-save">
{% trans "Save" %}
</button>
</div>
</form>
{% endblock %}

View File

@@ -0,0 +1,26 @@
{% extends "pretixcontrol/organizers/base.html" %}
{% load i18n %}
{% load static %}
{% load bootstrap3 %}
{% block inner %}
<h1>{% trans "Add sales channel" %}</h1>
<div class="list-group large-link-group">
{% for t in types %}
<a class="list-group-item" href="?type={{ t.identifier }}">
<h4>
{% if "." in t.icon %}
<img class="fa-like-image" src="{% static t.icon %}" alt="">
{% else %}
<span class="fa fa-fw fa-{{ t.icon }} text-muted"></span>
{% endif %}
{{ t.verbose_name }}
</h4>
{% if t.description %}
<p>
{{ t.description }}
</p>
{% endif %}
</a>
{% endfor %}
</div>
{% endblock %}

View File

@@ -0,0 +1,33 @@
{% extends "pretixcontrol/organizers/base.html" %}
{% load i18n %}
{% load bootstrap3 %}
{% block inner %}
<h1>{% trans "Delete sales channel:" %} {{ channel.label }}</h1>
<form action="" method="post" class="form-horizontal">
{% csrf_token %}
{% if is_allowed %}
<p>
{% blocktrans trimmed %}
Are you sure you want to delete this sales channel?
{% endblocktrans %}
{% else %}
<div class="alert alert-danger">
{% blocktrans trimmed %}
This sales channel cannot be deleted since it has already been used to sell orders or because it is
a core element of the system.
{% endblocktrans %}
</div>
{% endif %}
<div class="form-group submit-group">
<a href="{% url "control:organizer.channels" organizer=request.organizer.slug %}"
class="btn btn-default btn-cancel">
{% trans "Cancel" %}
</a>
{% if is_allowed %}
<button type="submit" class="btn btn-danger btn-save">
{% trans "Delete" %}
</button>
{% endif %}
</div>
</form>
{% endblock %}

View File

@@ -0,0 +1,27 @@
{% extends "pretixcontrol/organizers/base.html" %}
{% load i18n %}
{% load formset_tags %}
{% load bootstrap3 %}
{% block inner %}
<h1>{% trans "Sales channel:" %} {{ channel.label }}</h1>
<form class="form-horizontal" action="" method="post">
{% csrf_token %}
{% bootstrap_form_errors form layout="control" %}
{% bootstrap_field form.label layout="control" %}
<div class="form-group">
<label class="col-md-3 control-label" for="id_identifier">{% trans "Channel type" %}</label>
<div class="col-md-9">
<input type="text" value="{{ type.verbose_name }}" class="form-control" disabled>
</div>
</div>
{% bootstrap_field form.identifier layout="control" %}
<div class="form-group submit-group">
<button type="submit" class="btn btn-primary btn-save">
{% trans "Save" %}
</button>
</div>
</form>
{% endblock %}

View File

@@ -0,0 +1,64 @@
{% extends "pretixcontrol/organizers/base.html" %}
{% load i18n %}
{% load bootstrap3 %}
{% load static %}
{% block inner %}
<h1>{% trans "Sales channels" %}</h1>
<p>
{% blocktrans trimmed %}
On this page, you can manage the different channels your tickets can be sold through. This is useful
to unlock new revenue streams or to separate revenue between different sources for reporting purchases.
{% endblocktrans %}
</p>
<a href="{% url "control:organizer.channel.add" organizer=request.organizer.slug %}" class="btn btn-default">
<span class="fa fa-plus"></span>
{% trans "Add a new channel" %}
</a>
<form method="post">
{% csrf_token %}
<table class="table table-condensed table-hover">
<thead>
<tr>
<th>{% trans "Channel" %}</th>
<th>{% trans "Identifier" %}</th>
<th>{% trans "Channel type" %}</th>
<th class="action-col-2"></th>
<th class="action-col-2"></th>
</tr>
</thead>
<tbody data-dnd-url="{% url "control:organizer.channels.reorder" organizer=request.organizer.slug %}">
{% for c in channels %}
<tr data-dnd-id="{{ c.pk }}">
<td><strong>
<a href="{% url "control:organizer.channel.edit" organizer=request.organizer.slug channel=c.identifier %}">
{{ c.label }}
</a>
</strong></td>
<td>
<code>{{ c.identifier }}</code>
</td>
<td>
{% if "." in c.type_instance.icon %}
<img class="fa-like-image" src="{% static c.icon %}" alt="">
{% else %}
<span class="fa fa-fw fa-{{ c.type_instance.icon }} text-muted"></span>
{% endif %}
{{ c.type_instance.verbose_name }}
</td>
<td>
<button formaction="{% url "control:organizer.channel.up" organizer=request.organizer.slug channel=c.identifier %}" class="btn btn-default btn-sm sortable-up"{% if forloop.counter0 == 0 and not page_obj.has_previous %} disabled{% endif %}><i class="fa fa-arrow-up"></i></button>
<button formaction="{% url "control:organizer.channel.down" organizer=request.organizer.slug channel=c.identifier %}" class="btn btn-default btn-sm sortable-down"{% if forloop.revcounter0 == 0 and not page_obj.has_next %} disabled{% endif %}><i class="fa fa-arrow-down"></i></button>
<span class="dnd-container"></span>
</td>
<td class="text-right flip">
<a href="{% url "control:organizer.channel.edit" organizer=request.organizer.slug channel=c.identifier %}"
class="btn btn-default btn-sm"><i class="fa fa-edit"></i></a>
<a href="{% url "control:organizer.channel.delete" organizer=request.organizer.slug channel=c.identifier %}"
class="btn btn-danger btn-sm {% if c.type_instance.default_created %}disabled{% endif %}"><i class="fa fa-trash"></i></a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</form>
{% endblock %}

View File

@@ -2,6 +2,7 @@
{% load i18n %}
{% load bootstrap3 %}
{% load money %}
{% load static %}
{% block title %}
{% blocktrans trimmed with id=customer.identifier %}
Customer #{{ id }}
@@ -225,8 +226,13 @@
{{ o.event }}
</td>
<td>
<span class="fa fa-{{ o.sales_channel_obj.icon }} text-muted"
data-toggle="tooltip" title="{% trans o.sales_channel_obj.verbose_name %}"></span>
{% if "." in o.sales_channel.icon %}
<img src="{% static o.sales_channel.icon %}" class="fa-like-image"
data-toggle="tooltip" title="{{ o.sales_channel.label }}">
{% else %}
<span class="fa fa-{{ o.sales_channel.icon }} text-muted"
data-toggle="tooltip" title="{{ o.sales_channel.label }}"></span>
{% endif %}
{{ o.datetime|date:"SHORT_DATETIME_FORMAT" }}
{% if o.customer_id != customer.pk %}
<span class="fa fa-link text-muted"