Allow to link directly to voucher input form

This commit is contained in:
Raphael Michel
2021-12-06 18:09:38 +01:00
parent e1f924c4ce
commit b355733f53
4 changed files with 55 additions and 31 deletions

View File

@@ -0,0 +1,31 @@
{% load i18n %}
{% load eventurl %}
{% load rich_text %}
{% if event.settings.voucher_explanation_text %}
<div>
{{ event.settings.voucher_explanation_text|rich_text }}
</div>
{% endif %}
<form method="get" action="{% eventurl event "presale:event.redeem" cart_namespace=cart_namespace %}">
<div class="row row-voucher">
<div class="col-md-8 col-sm-6 col-xs-12">
<label for="voucher" class="sr-only">{% trans "Voucher code" %}
{% if "voucher_invalid" in request.GET %}<strong>{% trans "has error" context "form" %},</strong>{% endif %}
<i>{% trans "required" context "form" %}</i></label>
<div class="input-group{% if "voucher_invalid" in request.GET %} has-error{% endif %}">
<span class="input-group-addon"><i class="fa fa-ticket fa-fw" aria-hidden="true"></i></span>
<input type="text" class="form-control{% if "voucher_invalid" in request.GET %} has-error{% endif %}" name="voucher" id="voucher"
{% if "voucher_invalid" in request.GET %} aria-describedby="error-message"{% endif %}
placeholder="{% trans "Voucher code" %}" required="required">
</div>
</div>
<input type="hidden" name="subevent" value="{{ subevent.id|default_if_none:"" }}" />
<input type="hidden" name="next" value="{{ request.path }}" />
<div class="col-md-4 col-sm-6 col-xs-12">
<button class="btn btn-block btn-primary" type="submit">
{% trans "Redeem voucher" %}
</button>
</div>
<div class="clearfix"></div>
</div>
</form>

View File

@@ -295,33 +295,7 @@
{% if show_vouchers %}
<aside class="front-page" aria-labelledby="redeem-a-voucher">
<h3 id="redeem-a-voucher">{% trans "Redeem a voucher" %}</h3>
{% if event.settings.voucher_explanation_text %}
<div>
{{ event.settings.voucher_explanation_text|rich_text }}
</div>
{% endif %}
<form method="get" action="{% eventurl event "presale:event.redeem" cart_namespace=cart_namespace %}">
<div class="row row-voucher">
<div class="col-md-8 col-sm-6 col-xs-12">
<label for="voucher" class="sr-only">{% trans "Voucher code" %}
{% if "voucher_invalid" in request.GET %}<strong>{% trans "has error" context "form" %},</strong>{% endif %}
<i>{% trans "required" context "form" %}</i></label>
<div class="input-group{% if "voucher_invalid" in request.GET %} has-error{% endif %}">
<span class="input-group-addon"><i class="fa fa-ticket fa-fw" aria-hidden="true"></i></span>
<input type="text" class="form-control{% if "voucher_invalid" in request.GET %} has-error{% endif %}" name="voucher" id="voucher"
{% if "voucher_invalid" in request.GET %} aria-describedby="error-message"{% endif %}
placeholder="{% trans "Voucher code" %}" required="required">
</div>
</div>
<input type="hidden" name="subevent" value="{{ subevent.id|default_if_none:"" }}" />
<div class="col-md-4 col-sm-6 col-xs-12">
<button class="btn btn-block btn-primary" type="submit">
{% trans "Redeem voucher" %}
</button>
</div>
<div class="clearfix"></div>
</div>
</form>
{% include "pretixpresale/event/fragment_voucher_form.html" %}
</aside>
{% endif %}
{% if not cart_namespace %}

View File

@@ -0,0 +1,14 @@
{% extends "pretixpresale/event/base.html" %}
{% load i18n %}
{% load l10n %}
{% load money %}
{% load eventurl %}
{% load eventsignal %}
{% load thumb %}
{% load rich_text %}
{% block title %}{% trans "Voucher redemption" %}{% endblock %}
{% block content %}
<h2>{% trans "Redeem a voucher" %}</h2>
{% include "pretixpresale/event/fragment_voucher_form.html" %}
{% endblock %}