Add expiry dates and individual conditions to gift cards (#1656)

* Add expiry dates and individual conditions to gift cards

* Display refund gift cards with more details and prettier interface

* Allow to set gift card expiry and conditions when cancelling event

* Extend gift card search

* Fix #1565 -- Some gift card filters

* Improve list of gift cards

* Allow to edit gift cards

* Note on validity
This commit is contained in:
Raphael Michel
2020-04-21 15:57:02 +02:00
committed by GitHub
parent d9fd4b33a0
commit f2844ac686
31 changed files with 450 additions and 70 deletions

View File

@@ -103,27 +103,62 @@
</div>
{% endif %}
{% if refunds %}
<div class="alert alert-info">
{% for r in refunds %}
{% if r.state == "created" or r.state == "transit" %}
{% blocktrans trimmed with amount=r.amount|money:request.event.currency %}
A refund of {{ amount }} will be sent out to you soon, please be patient.
{% endblocktrans %}
{% elif r.state == "done" %}
{% if r.provider == "giftcard" and "gift_card_code" in r.info_data %}
{% blocktrans trimmed with amount=r.amount|money:request.event.currency code=r.info_data.gift_card_code %}
We've issued your refund of {{ amount }} as a gift card. On your next purchase with
us, you can use the gift card code <strong>{{ code }}</strong> during payment.
{% endblocktrans %}
{% else %}
{% blocktrans trimmed with amount=r.amount|money:request.event.currency %}
A refund of {{ amount }} has been sent to you. Depending on the payment method, please allow for up to 14 days until it shows up
on your statement.
{% endblocktrans %}
{% endif %}
{% endif %}
{% if not forloop.last %}<br />{% endif %}
{% endfor %}
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
{% trans "Refunds" %}
</h3>
</div>
<ul class="list-group">
{% for r in refunds %}
<li class="list-group-item">
{% if r.state == "created" or r.state == "transit" %}
{% blocktrans trimmed with amount=r.amount|money:request.event.currency %}
A refund of {{ amount }} will be sent out to you soon, please be patient.
{% endblocktrans %}
{% elif r.state == "done" %}
{% if r.provider == "giftcard" %}
<a href="#" class="print-this-page btn btn-default btn-sm pull-right hidden-print">
<span class="fa fa-print"></span>
{% trans "Print" %}
</a>
{% blocktrans trimmed with amount=r.amount|money:request.event.currency %}
We've issued your refund of {{ amount }} as a gift card. On your next purchase with
us, you can use the following gift card code during payment:
{% endblocktrans %}
<div class="text-center refund-gift-card-code">
<span class="fa fa-credit-card"></span>
{{ r.giftcard.secret }}
</div>
{% if r.giftcard.value != r.amount %}
<small>
{% blocktrans trimmed with value=r.giftcard.value|money:request.event.currency %}
The current value of your gift card is {{ value }}.
{% endblocktrans %}
</small>
{% endif %}
{% if r.giftcard.expires %}
<small>
{% blocktrans trimmed with expiry=r.giftcard.expires|date:"SHORT_DATE_FORMAT" %}
This gift card is valid until {{ expiry }}.
{% endblocktrans %}
</small>
{% endif %}
{% if r.giftcard.conditions %}
<small>
{{ r.giftcard.conditions }}
</small>
{% endif %}
{% else %}
{% blocktrans trimmed with amount=r.amount|money:request.event.currency %}
A refund of {{ amount }} has been sent to you. Depending on the payment method, please allow for up to 14 days until it shows up
on your statement.
{% endblocktrans %}
{% endif %}
{% endif %}
{% endfor %}
</li>
</ul>
</div>
{% endif %}
{% endif %}

View File

@@ -81,36 +81,54 @@
<strong>
{% trans "The refund will be issued in form of a gift card that you can use for further purchases." %}
</strong>
{% if request.event.organizer.default_gift_card_expiry %}
<p class="help-block">
{% blocktrans trimmed with expiry_date=request.event.organizer.default_gift_card_expiry|date:"SHORT_DATE_FORMAT" %}
Your gift card will be valid until {{ expiry_date }}.
{% endblocktrans %}
</p>
{% endif %}
{% elif request.event.settings.cancel_allow_user_paid_refund_as_giftcard == "option" %}
<div class="radio">
<label>
<input type="radio" name="giftcard" value="true" checked>
<input type="radio" name="giftcard" value="true" checked id="id_giftcard">
<strong>{% trans "I want the refund as a gift card for later purchases" %}</strong>
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="giftcard" value="false" checked>
<input type="radio" name="giftcard" value="false" checked id="id_payout">
<strong>{% trans "I want the refund to be sent to my original payment method" %}</strong>
</label>
</div>
{% if can_auto_refund %}
<p class="help-block">
{% blocktrans trimmed %}
The refund amount will automatically be sent back to your original payment method. Depending
on the payment method, please allow for up to two weeks before this appears on your
statement.
{% endblocktrans %}
</p>
{% else %}
<p class="help-block">
{% blocktrans trimmed %}
With the payment method you used, the refund amount <strong>can not be sent back to you
automatically</strong>. Instead, the event organizer will need to initiate the transfer
manually. Please be patient as this might take a bit longer.
{% endblocktrans %}
</p>
{% endif %}
<div data-display-dependency="#id_giftcard">
{% if request.event.organizer.default_gift_card_expiry %}
<p class="help-block">
{% blocktrans trimmed with expiry_date=request.event.organizer.default_gift_card_expiry|date:"SHORT_DATE_FORMAT" %}
Your gift card will be valid until {{ expiry_date }}.
{% endblocktrans %}
</p>
{% endif %}
</div>
<div data-display-dependency="#id_payout">
{% if can_auto_refund %}
<p class="help-block">
{% blocktrans trimmed %}
The refund amount will automatically be sent back to your original payment method. Depending
on the payment method, please allow for up to two weeks before this appears on your
statement.
{% endblocktrans %}
</p>
{% else %}
<p class="help-block">
{% blocktrans trimmed %}
With the payment method you used, the refund amount <strong>can not be sent back to you
automatically</strong>. Instead, the event organizer will need to initiate the transfer
manually. Please be patient as this might take a bit longer.
{% endblocktrans %}
</p>
{% endif %}
</div>
{% else %}
{% if can_auto_refund %}
<p>

View File

@@ -20,7 +20,7 @@ from django.views.decorators.clickjacking import xframe_options_exempt
from django.views.generic import TemplateView, View
from pretix.base.models import (
CachedTicket, Invoice, Order, OrderPosition, Quota,
CachedTicket, GiftCard, Invoice, Order, OrderPosition, Quota,
)
from pretix.base.models.orders import (
CachedCombinedTicket, OrderFee, OrderPayment, OrderRefund, QuestionAnswer,
@@ -230,6 +230,10 @@ class OrderDetails(EventViewMixin, OrderDetailMixin, CartMixin, TicketPageMixin,
).exclude(
provider__in=('offsetting', 'reseller', 'boxoffice', 'manual')
)
for r in ctx['refunds']:
if r.provider == 'giftcard':
gc = GiftCard.objects.get(pk=r.info_data.get('gift_card'))
r.giftcard = gc
return ctx