Show issued gift card in order view

This commit is contained in:
Raphael Michel
2019-10-17 17:07:59 +02:00
parent 1a07686b79
commit 767e679140
5 changed files with 26 additions and 12 deletions

View File

@@ -310,6 +310,14 @@
{% eventsignal event "pretix.control.signals.order_position_buttons" order=order position=line request=request %} {% eventsignal event "pretix.control.signals.order_position_buttons" order=order position=line request=request %}
</div> </div>
{% endif %} {% 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 %} {% if line.has_questions %}
<dl> <dl>
{% if line.item.admission and event.settings.attendee_names_asked %} {% if line.item.admission and event.settings.attendee_names_asked %}

View File

@@ -85,7 +85,6 @@
{% endblocktrans %} {% endblocktrans %}
</p> </p>
<ul> <ul>
{% for gca in request.organizer.gift_card_issuer_acceptance.all %} {% for gca in request.organizer.gift_card_issuer_acceptance.all %}
<li> <li>
<strong>{{ gca.issuer }}</strong> <strong>{{ gca.issuer }}</strong>
@@ -98,17 +97,17 @@
<em>{% trans "You are currently not accepting gift cards from other organizers." %}</em> <em>{% trans "You are currently not accepting gift cards from other organizers." %}</em>
</li> </li>
{% endfor %} {% endfor %}
<li>
{% if other_organizers %} {% if other_organizers %}
<li> <li>
<select name="add" class="form-control"> <select name="add" class="form-control">
<option></option> <option></option>
{% for o in other_organizers %} {% for o in other_organizers %}
<option value="{{ o.slug }}">{{ o }}</option> <option value="{{ o.slug }}">{{ o }}</option>
{% endfor %} {% endfor %}
</select> </select>
<button class="btn btn-primary btn-sm" type="submit"><span class="fa fa-plus"></span></button> <button class="btn btn-primary btn-sm" type="submit"><span class="fa fa-plus"></span></button>
</li> </li>
{% endif %}
</ul> </ul>
</fieldset> </fieldset>
</form> </form>

View File

@@ -237,7 +237,7 @@ class OrderDetail(OrderView):
).select_related( ).select_related(
'item', 'variation', 'addon_to', 'tax_rule' 'item', 'variation', 'addon_to', 'tax_rule'
).prefetch_related( ).prefetch_related(
'item__questions', 'item__questions', 'issued_gift_cards',
Prefetch('answers', queryset=QuestionAnswer.objects.prefetch_related('options').select_related('question')), Prefetch('answers', queryset=QuestionAnswer.objects.prefetch_related('options').select_related('question')),
'checkins', 'checkins__list' 'checkins', 'checkins__list'
).order_by('positionid') ).order_by('positionid')

View File

@@ -33,7 +33,14 @@
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if line.issued_gift_cards %}
<dl>
{% for gc in line.issued_gift_cards.all %}
<dt>{% trans "Gift card code" %}</dt>
<dd>{{ gc.secret }}</dd>
{% endfor %}
</dl>
{% endif %}
{% if line.has_questions %} {% if line.has_questions %}
<dl> <dl>
{% if line.item.admission and event.settings.attendee_names_asked %} {% if line.item.admission and event.settings.attendee_names_asked %}

View File

@@ -163,7 +163,7 @@ class OrderDetails(EventViewMixin, OrderDetailMixin, CartMixin, TicketPageMixin,
ctx = super().get_context_data(**kwargs) ctx = super().get_context_data(**kwargs)
ctx['cart'] = self.get_cart( ctx['cart'] = self.get_cart(
answers=True, downloads=ctx['can_download'], answers=True, downloads=ctx['can_download'],
queryset=self.order.positions.select_related('tax_rule'), queryset=self.order.positions.prefetch_related('issued_gift_cards').select_related('tax_rule'),
order=self.order order=self.order
) )
ctx['can_download_multi'] = any([b['multi'] for b in self.download_buttons]) and ( ctx['can_download_multi'] = any([b['multi'] for b in self.download_buttons]) and (