Merge pull request #1396 from pretix/giftcard

Support for gift cards
This commit is contained in:
Raphael Michel
2019-10-18 17:08:45 +02:00
committed by GitHub
58 changed files with 2677 additions and 72 deletions

View File

@@ -0,0 +1,10 @@
{% load i18n %}
<p>
{% blocktrans %}
If you have a gift card, please enter the gift card code here. If the gift card does not have
enough credit to pay for the full order, you will be shown this page again and you can either
redeem another gift card or select a different payment method for the difference.
{% endblocktrans %}
</p>
<input name="giftcard" class="form-control" placeholder="{% trans "Gift card code" %}">

View File

@@ -0,0 +1,8 @@
{% load i18n %}
<p>
{% blocktrans %}
Your gift card will be used to pay for this order. If the credit on the gift card is lower than the order total, you will be able to pay the
difference with a different payment method. If the credit is higher than the order total, you will be able to re-use the gift card in the future.
{% endblocktrans %}
</p>

View File

@@ -0,0 +1,12 @@
{% load i18n %}
<dl class="dl-horizontal">
<dt>{% trans "Gift card code" %}</dt>
<dd>
<a href="{% url "control:organizer.giftcard" organizer=gc.issuer.slug giftcard=gc.pk %}">
{{ gc.secret }}
</a>
</dd>
<dt>{% trans "Issuer" %}</dt>
<dd>{{ gc.issuer }}</dd>
</dl>

View File

@@ -55,6 +55,7 @@
</fieldset>
<fieldset>
<legend>{% trans "Additional settings" %}</legend>
{% bootstrap_field form.issue_giftcard layout="control" %}
{% bootstrap_field form.show_quota_left layout="control" %}
{% for f in plugin_forms %}
{% bootstrap_form f layout="control" %}

View File

@@ -310,6 +310,14 @@
{% eventsignal event "pretix.control.signals.order_position_buttons" order=order position=line request=request %}
</div>
{% endif %}
{% if line.issued_gift_cards %}
<dl>
{% for gc in line.issued_gift_cards.all %}
<dt>{% trans "Gift card code" %}</dt>
<dd><a href="{% url "control:organizer.giftcard" organizer=gc.issuer.slug giftcard=gc.pk %}">{{ gc.secret }}</a></dd>
{% endfor %}
</dl>
{% endif %}
{% if line.has_questions %}
<dl>
{% if line.item.admission and event.settings.attendee_names_asked %}

View File

@@ -0,0 +1,91 @@
{% extends "pretixcontrol/organizers/base.html" %}
{% load i18n %}
{% load bootstrap3 %}
{% load money %}
{% block inner %}
<h1>
{% blocktrans trimmed with card=card.secret %}
Gift card: {{ card }}
{% endblocktrans %}
{% if card.testmode %}
<span class="label label-warning">{% trans "TEST MODE" %}</span>
{% endif %}
</h1>
<div class="panel panel-primary items">
<div class="panel-heading">
<h3 class="panel-title">
{% trans "Details" %}
</h3>
</div>
<div class="panel-body">
<dl class="dl-horizontal">
<dt>{% trans "Gift card code" %}</dt>
<dd>{{ card.secret }}</dd>
<dt>{% trans "Creation date" %}</dt>
<dd>{{ card.issuance|date:"SHORT_DATETIME_FORMAT" }}</dd>
<dt>{% trans "Current value" %}</dt>
<dd>{{ card.value|money:card.currency }}</dd>
<dt>{% trans "Currency" %}</dt>
<dd>{{ card.currency }}</dd>
{% if card.issued_in %}
<dt>{% trans "Issued through sale" %}</dt>
<dd>
<a href="{% url "control:event.order" event=card.issued_in.order.event.slug organizer=card.issued_in.order.event.organizer.slug code=card.issued_in.order.code %}">
{{ card.issued_in.order.full_code }}</a>-{{ card.issued_in.positionid }}
</dd>
{% endif %}
</dl>
</div>
</div>
<div class="panel panel-default items">
<div class="panel-heading">
<h3 class="panel-title">
{% trans "Transactions" %}
</h3>
</div>
<table class="panel-body table">
<thead>
<tr>
<th>{% trans "Date" %}</th>
<th>{% trans "Order" %}</th>
<th class="text-right">{% trans "Value" %}</th>
</tr>
</thead>
<tbody>
{% for t in card.transactions.all %}
<tr>
<td>{{ t.datetime|date:"SHORT_DATETIME_FORMAT" }}</td>
<td>
{% if t.order %}
<a href="{% url "control:event.order" event=t.order.event.slug organizer=t.order.event.organizer.slug code=t.order.code %}">
{{ t.order.full_code }}
</a>
{% else %}
<em>{% trans "Manual transaction" %}</em>
{% endif %}
</td>
<td class="text-right">
{{ t.value|money:card.currency }}
</td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<td></td>
<td></td>
<td class="text-right">
<form class="helper-display-inline form-inline" method="post" action="">
{% csrf_token %}
<input type="text" class="form-control input-sm" placeholder="{% trans "Value" %}" name="value">
<button class="btn btn-primary">
<span class="fa fa-plus"></span>
</button>
</form>
</td>
</tr>
</tfoot>
</table>
</div>
{% endblock %}

View File

@@ -0,0 +1,19 @@
{% extends "pretixcontrol/organizers/base.html" %}
{% load i18n %}
{% load bootstrap3 %}
{% block inner %}
<h1>{% trans "Create a new gift card" %}</h1>
<form class="form-horizontal" action="" method="post">
{% csrf_token %}
{% bootstrap_form_errors form %}
{% bootstrap_field form.secret layout="control" %}
{% bootstrap_field form.value layout="control" %}
{% bootstrap_field form.currency layout="control" %}
{% bootstrap_field form.testmode 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,117 @@
{% extends "pretixcontrol/organizers/base.html" %}
{% load i18n %}
{% load bootstrap3 %}
{% load money %}
{% block inner %}
<h1>
{% trans "Issued gift cards" %}
</h1>
{% if giftcards|length == 0 and not filter_form.filtered %}
<div class="empty-collection">
<p>
{% blocktrans trimmed %}
You haven't issued any gift cards yet. You can either set up a product in an event shop to sell gift cards,
or you can manually issue gift cards.
{% endblocktrans %}
</p>
<a href="{% url "control:organizer.giftcard.add" organizer=request.organizer.slug %}"
class="btn btn-default btn-lg"><i class="fa fa-plus"></i> {% trans "Manually issue a gift card" %}
</a>
</div>
{% else %}
<form class="row filter-form" action="" method="get">
<div class="col-md-10 col-sm-6 col-xs-12">
{% bootstrap_field filter_form.query layout='inline' %}
</div>
<div class="col-md-2 col-sm-6 col-xs-12">
<button class="btn btn-primary btn-block" type="submit">
<span class="fa fa-filter"></span>
<span class="hidden-md">
{% trans "Filter" %}
</span>
</button>
</div>
</form>
<p>
<a href="{% url "control:organizer.giftcard.add" organizer=request.organizer.slug %}"
class="btn btn-default"><i class="fa fa-plus"></i> {% trans "Manually issue a gift card" %}</a>
</p>
<div class="table-responsive">
<table class="table table-condensed table-hover">
<thead>
<tr>
<th>{% trans "Gift card code" %}</th>
<th>{% trans "Creation date" %}</th>
<th class="text-right">{% trans "Current value" %}</th>
<th></th>
</tr>
</thead>
<tbody>
{% for g in giftcards %}
<tr>
<td>
<a href="{% url "control:organizer.giftcard" organizer=request.organizer.slug giftcard=g.id %}">
<strong>{{ g.secret }}</strong></a>
{% if g.testmode %}
<span class="label label-warning">{% trans "TEST MODE" %}</span>
{% endif %}
</td>
<td>{{ g.issuance|date:"SHORT_DATETIME_FORMAT" }}</td>
<td class="text-right">
{{ g.cached_value|money:g.currency }}
</td>
<td class="text-right">
<a href="{% url "control:organizer.giftcard" organizer=request.organizer.slug giftcard=g.id %}"
class="btn btn-default btn-sm" data-toggle="tooltip" title="{% trans "Details" %}">
<i class="fa fa-eye"></i>
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</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 %}

View File

@@ -22,6 +22,7 @@
<fieldset>
<legend>{% trans "Organizer permissions" %}</legend>
{% bootstrap_field form.can_create_events layout="control" %}
{% bootstrap_field form.can_manage_gift_cards layout="control" %}
{% bootstrap_field form.can_change_teams layout="control" %}
{% bootstrap_field form.can_change_organizer_settings layout="control" %}
</fieldset>