mirror of
https://github.com/pretix/pretix.git
synced 2026-09-12 16:04:42 +00:00
Display answers in confirm step, fix file upload/download
This commit is contained in:
@@ -1564,6 +1564,7 @@ class ConfirmStep(CartMixin, AsyncAction, TemplateFlowStep):
|
||||
ctx['addr'] = self.invoice_address
|
||||
ctx['confirm_messages'] = self.confirm_messages
|
||||
ctx['cart_session'] = self.cart_session
|
||||
ctx['checkout_session'] = self.checkout_session
|
||||
ctx['invoice_address_asked'] = self.address_asked
|
||||
ctx['customer'] = self.cart_customer
|
||||
|
||||
|
||||
@@ -162,6 +162,26 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% if checkout_session.answers.all %}
|
||||
<div class="panel panel-default panel-contact">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">
|
||||
{% trans "Additional order information" %}
|
||||
<a href="{% eventurl request.event "presale:event.checkout" step="questions" cart_namespace=cart_namespace|default_if_none:"" %}" aria-label="{% trans "Modify contact information" %}" class="h6">
|
||||
<span class="fa fa-edit" aria-hidden="true"></span>{% trans "Modify" %}
|
||||
</a>
|
||||
</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<dl class="dl-horizontal">
|
||||
{% for ans in checkout_session.answers.all %}
|
||||
<dt>{{ ans.question.question }}</dt>
|
||||
<dd>{% include "pretixpresale/event/fragment_question_answer.html" with request=request question=ans.question answer=ans %}</dd>
|
||||
{% endfor %}
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% if confirm_messages %}
|
||||
|
||||
@@ -206,27 +206,7 @@
|
||||
{% for q in line.questions %}
|
||||
<dt>{{ q.question }}</dt>
|
||||
<dd>
|
||||
{% if q.answer %}
|
||||
{% if q.answer.file %}
|
||||
<span class="fa fa-file" aria-hidden="true"></span>
|
||||
<a href="{{ q.answer.frontend_file_url }}?token={% answer_token request q.answer %}">
|
||||
{{ q.answer.file_name }}
|
||||
</a>
|
||||
{% if q.answer.is_image %}
|
||||
<br>
|
||||
<a href="{{ q.answer.frontend_file_url }}?token={% answer_token request q.answer %}" data-lightbox="order"
|
||||
class="answer-thumb">
|
||||
<img src="{{ q.answer.frontend_file_url }}?token={% answer_token request q.answer %}" alt="{% trans "The image you previously uploaded" %}">
|
||||
</a>
|
||||
{% endif %}
|
||||
{% elif q.type == "M" %}
|
||||
{{ q.answer|rich_text_snippet }}
|
||||
{% else %}
|
||||
{{ q.answer|linebreaksbr }}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<em class="text-muted">{% trans "not answered" %}</em>
|
||||
{% endif %}
|
||||
{% include "pretixpresale/event/fragment_question_answer.html" with request=request question=q answer=q.answer %}
|
||||
</dd>
|
||||
{% endfor %}
|
||||
{% for q in line.additional_answers %}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
{% load safelink %}
|
||||
{% load i18n %}
|
||||
{% load rich_text %}
|
||||
{% if answer %}
|
||||
{% if answer.file %}
|
||||
<span class="fa fa-file" aria-hidden="true"></span>
|
||||
<a href="{{ answer.frontend_file_url }}?token={% answer_token request answer %}">
|
||||
{{ answer.file_name }}
|
||||
</a>
|
||||
{% if answer.is_image %}
|
||||
<br>
|
||||
<a href="{{ answer.frontend_file_url }}?token={% answer_token request answer %}" data-lightbox="order"
|
||||
class="answer-thumb">
|
||||
<img src="{{ answer.frontend_file_url }}?token={% answer_token request answer %}" alt="{% trans "The image you previously uploaded" %}">
|
||||
</a>
|
||||
{% endif %}
|
||||
{% elif question.type == "M" %}
|
||||
{{ answer|rich_text_snippet }}
|
||||
{% else %}
|
||||
{{ answer|linebreaksbr }}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<em class="text-muted">{% trans "not answered" %}</em>
|
||||
{% endif %}
|
||||
@@ -388,6 +388,7 @@ def get_or_create_cart_id(request, create=True):
|
||||
if 'carts' in request.session:
|
||||
request.session['carts'][current_id] = {}
|
||||
else:
|
||||
# We found a valid, existing cart.
|
||||
return current_id
|
||||
|
||||
cart_data = {}
|
||||
@@ -398,6 +399,7 @@ def get_or_create_cart_id(request, create=True):
|
||||
cart_data['widget_data'] = cached_widget_data
|
||||
else:
|
||||
if not create:
|
||||
# There is no existing cart for this request and we're not supposed to create a new one.
|
||||
return None
|
||||
new_id = generate_cart_id(request, prefix=prefix)
|
||||
|
||||
@@ -846,9 +848,10 @@ class RedeemView(NoSearchIndexViewMixin, EventViewMixin, CartMixin, TemplateView
|
||||
class AnswerDownload(EventViewMixin, View):
|
||||
def get(self, request, *args, **kwargs):
|
||||
answid = kwargs.get('answer')
|
||||
cart_id = get_or_create_cart_id(self.request)
|
||||
answer = get_object_or_404(
|
||||
QuestionAnswer,
|
||||
cartposition__cart_id=get_or_create_cart_id(self.request),
|
||||
Q(cartposition__cart_id=cart_id) | Q(checkoutsession__cart_id=cart_id),
|
||||
id=answid
|
||||
)
|
||||
if not answer.file:
|
||||
|
||||
Reference in New Issue
Block a user