Gift cards: Improved support for cross-organizer acceptance (#3311)

Co-authored-by: Martin Gross <martin@pc-coholic.de>
This commit is contained in:
Raphael Michel
2023-06-15 14:17:40 +02:00
committed by GitHub
parent b3c917925c
commit f8be8296dd
22 changed files with 605 additions and 139 deletions

View File

@@ -6,6 +6,12 @@
<a href="{% url "control:organizer.giftcard" organizer=gc.issuer.slug giftcard=gc.pk %}">
{{ gc.secret }}
</a>
{% if gc.issuer != request.organizer %}
<span class="text-muted">
<br>
<span class="fa fa-group"></span> {{ gc.issuer }}
</span>
{% endif %}
</dd>
<dt>{% trans "Issuer" %}</dt>
<dd>{{ gc.issuer }}</dd>

View File

@@ -0,0 +1,19 @@
{% extends "pretixcontrol/organizers/base.html" %}
{% load i18n %}
{% load urlreplace %}
{% load bootstrap3 %}
{% load money %}
{% block inner %}
<h1>
{% trans "Invite organizer" %}
</h1>
<form class="form-horizontal" action="" method="post">
{% csrf_token %}
{% bootstrap_form form 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,150 @@
{% extends "pretixcontrol/organizers/base.html" %}
{% load i18n %}
{% load urlreplace %}
{% load bootstrap3 %}
{% load money %}
{% block inner %}
<h1>
{% trans "Gift cards acceptance" %}
</h1>
<p>
{% blocktrans trimmed %}
This feature allows you to configure acceptance of gift cards across multiple organizer accounts.
{% endblocktrans %}
</p>
<form method="post">
{% csrf_token %}
<h2>
{% trans "Other organizers you accept gift cards from" %}
</h2>
{% if issuer_acceptance|length == 0 and not filter_form.filtered %}
<p>
{% blocktrans trimmed %}
You are not accepting gift cards from other organizers yet. If you want to do so, the other
organizer can add you to their list and afterwards, you can confirm this here.
{% endblocktrans %}
</p>
{% else %}
<div class="table-responsive">
<table class="table table-condensed table-hover">
<thead>
<tr>
<th>{% trans "Organizer" %}</th>
<th>{% trans "Status" %}</th>
<th>{% trans "Reusable media" %}</th>
<th></th>
</tr>
</thead>
<tbody>
{% for gca in issuer_acceptance %}
<tr>
<td>
{{ gca.issuer.name }}<br><code>{{ gca.issuer.slug }}</code>
</td>
<td>
{% if gca.active %}
{% trans "active" %}
{% else %}
{% trans "invited" %}
{% endif %}
</td>
<td>
{% if gca.reusable_media %}
{% trans "active" %}
{% else %}
{% trans "disabled" %}
{% endif %}
</td>
<td class="text-right">
{% if gca.active %}
<button class="btn btn-danger" name="delete_issuer" value="{{ gca.issuer.slug }}">
{% trans "Remove" %}
</button>
{% else %}
<button class="btn btn-success" name="accept_issuer" value="{{ gca.issuer.slug }}">
{% trans "Accept" %}
</button>
<button class="btn btn-danger" name="delete_issuer" value="{{ gca.issuer.slug }}">
{% trans "Decline" %}
</button>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</form>
<form method="post">
{% csrf_token %}
<h2>
{% trans "Other organizers accepting gift cards from you" %}
</h2>
<p>
{% blocktrans trimmed %}
You can invite other organizers to accept your gift cards. After you have done so, they need to go
to the same page in their account and accept your invitation. Note that other organizers will be able
to add money to gift cards as well that you will need to collect form them. It is your responsibility
to handle the exchange of money to offset the transactions between the two organizers.
{% endblocktrans %}
</p>
<p>
{% blocktrans trimmed %}
You can optionally control whether they can access your reusable media. This is required if you want
them to participate in a shared system with e.g. NFC payment chips.
{% endblocktrans %}
{% blocktrans trimmed %}
You should only use this option for organizers you trust, since (depending on the activated medium types)
this will grant the other organizer access to cryptographic key material required to interact with
the media type.
{% endblocktrans %}
</p>
<a href="{% url "control:organizer.giftcards.acceptance.invite" organizer=request.organizer.slug %}" class="btn btn-default">
{% trans "Invite new organizer" %}
</a>
<div class="table-responsive">
<table class="table table-condensed table-hover">
<thead>
<tr>
<th>{% trans "Organizer" %}</th>
<th>{% trans "Status" %}</th>
<th>{% trans "Reusable media" %}</th>
<th></th>
</tr>
</thead>
<tbody>
{% for gca in acceptor_acceptance %}
<tr>
<td>
{{ gca.acceptor.name }}<br><code>{{ gca.acceptor.slug }}</code>
</td>
<td>
{% if gca.active %}
{% trans "active" %}
{% else %}
{% trans "invited" %}
{% endif %}
</td>
<td>
{% if gca.reusable_media %}
{% trans "active" %}
{% else %}
{% trans "disabled" %}
{% endif %}
</td>
<td class="text-right">
<button class="btn btn-danger" name="delete_acceptor" value="{{ gca.acceptor.slug }}">
{% trans "Remove" %}
</button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</form>
{% include "pretixcontrol/pagination.html" %}
{% endblock %}

View File

@@ -99,44 +99,4 @@
</div>
{% include "pretixcontrol/pagination.html" %}
{% endif %}
{% if not is_paginated or page_obj.number == 1 %}
<form action="" method="post" class="form-inline">
{% csrf_token %}
<fieldset>
<legend>{% trans "Accepted gift cards of other organizers" %}</legend>
<p>
{% blocktrans trimmed %}
If you have access to multiple organizer accounts, you can configure that ticket shops in
this account will also accept gift codes issued through a different organizer account, and
vice versa.
{% endblocktrans %}
</p>
<ul>
{% for gca in request.organizer.gift_card_issuer_acceptance.all %}
<li>
<strong>{{ gca.issuer }}</strong>
<button type="submit" name="del" value="{{ gca.issuer.slug }}" class="btn btn-xs btn-danger">
<span class="fa fa-trash"></span>
</button>
</li>
{% empty %}
<li>
<em>{% trans "You are currently not accepting gift cards from other organizers." %}</em>
</li>
{% endfor %}
{% if other_organizers %}
<li>
<select name="add" class="form-control input-sm">
<option></option>
{% for o in other_organizers %}
<option value="{{ o.slug }}">{{ o }}</option>
{% endfor %}
</select>
<button class="btn btn-primary btn-sm" type="submit"><span class="fa fa-plus"></span></button>
</li>
{% endif %}
</ul>
</fieldset>
</form>
{% endif %}
{% endblock %}