mirror of
https://github.com/pretix/pretix.git
synced 2026-05-07 15:34:02 +00:00
Basic confirmation page
This commit is contained in:
@@ -44,6 +44,9 @@
|
||||
border-top: 1px solid @table-border-color;
|
||||
}
|
||||
}
|
||||
.panel-primary .panel-heading a {
|
||||
color: white;
|
||||
}
|
||||
.checkout-button-row {
|
||||
padding: 15px 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
{% extends "pretixpresale/event/base.html" %}
|
||||
{% load i18n %}
|
||||
{% load bootstrap3 %}
|
||||
{% block title %}{% trans "Confirm order" %}{% endblock %}
|
||||
{% block content %}
|
||||
<h2>{% trans "Confirm order" %}</h2>
|
||||
<p>{% trans "Please review the details below and confirm your order." %}</p>
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<div class="panel panel-primary cart">
|
||||
<div class="panel-heading">
|
||||
<div class="pull-right">
|
||||
<a href="{% url "presale:event.index" organizer=request.event.organizer.slug event=request.event.slug %}">{% trans "Modify" %}</a>
|
||||
</div>
|
||||
<h3 class="panel-title">
|
||||
{% trans "Your cart" %}
|
||||
</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{% include "pretixpresale/event/fragment_cart.html" with cart=cart event=request.event editable=False %}
|
||||
<div class="row-fluid">
|
||||
<div class="col-md-6 col-xs-12">
|
||||
{% if cart.minutes_left > 0 %}
|
||||
<em>{% blocktrans trimmed with minutes=cart.minutes_left %}
|
||||
The items in your cart are reserved for you for {{ minutes }} minutes.
|
||||
{% endblocktrans %}</em>
|
||||
{% else %}
|
||||
<em>{% trans "The items in your cart are no longer reserved for you." %}</em>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{# TODO: Question answers #}
|
||||
{# TODO: Payment method #}
|
||||
<div class="row checkout-button-row">
|
||||
<div class="col-md-4 col-md-offset-8">
|
||||
<button class="btn btn-block btn-primary btn-lg" type="submit">
|
||||
{% trans "Place binding order" %}
|
||||
</button>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
@@ -52,6 +52,18 @@
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% if cart.payment_fee %}
|
||||
{# TODO: Tax rate? #}
|
||||
<div class="row-fluid cart-row">
|
||||
<div class="col-md-4 col-xs-6">
|
||||
<strong>{% trans "Payment method fee" %}</strong>
|
||||
</div>
|
||||
<div class="col-md-3 col-xs-6 col-md-offset-5 price">
|
||||
<strong>{{ event.currency }} {{ cart.payment_fee|floatformat:2 }}</strong>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="row-fluid cart-row total">
|
||||
<div class="col-md-4 col-xs-6">
|
||||
<strong>{% trans "Total" %}</strong>
|
||||
|
||||
@@ -16,6 +16,8 @@ urlpatterns = patterns(
|
||||
url(r'^checkout$', pretix.presale.views.checkout.CheckoutStart.as_view(), name='event.checkout.start'),
|
||||
url(r'^checkout/payment$', pretix.presale.views.checkout.PaymentDetails.as_view(),
|
||||
name='event.checkout.payment'),
|
||||
url(r'^checkout/confirm$', pretix.presale.views.checkout.OrderConfirm.as_view(),
|
||||
name='event.checkout.confirm'),
|
||||
url(r'^login$', pretix.presale.views.event.EventLogin.as_view(), name='event.checkout.login'),
|
||||
)
|
||||
)),
|
||||
|
||||
@@ -8,6 +8,7 @@ from django.db.models import Q
|
||||
from django.utils.timezone import now
|
||||
|
||||
from pretix.base.models import CartPosition
|
||||
from pretix.base.signals import register_payment_providers
|
||||
|
||||
|
||||
class EventLoginRequiredMixin:
|
||||
@@ -59,10 +60,21 @@ class CartDisplayMixin:
|
||||
group.total = group.count * group.price
|
||||
positions.append(group)
|
||||
|
||||
total = sum(p.total for p in positions)
|
||||
|
||||
payment_fee = 0
|
||||
if 'payment' in self.request.session:
|
||||
responses = register_payment_providers.send(self.request.event)
|
||||
for receiver, response in responses:
|
||||
provider = response(self.request.event)
|
||||
if provider.identifier == self.request.session['payment']:
|
||||
payment_fee = provider.calculate_fee(total)
|
||||
|
||||
return {
|
||||
'positions': positions,
|
||||
'raw': cartpos,
|
||||
'total': sum(p.total for p in positions),
|
||||
'total': total + payment_fee,
|
||||
'payment_fee': payment_fee,
|
||||
'minutes_left': (
|
||||
max(min(p.expires for p in positions) - now(), timedelta()).seconds // 60
|
||||
if positions else 0
|
||||
|
||||
@@ -76,7 +76,7 @@ class QuestionsForm(forms.Form):
|
||||
self.fields['question_%s' % q.identity] = field
|
||||
|
||||
|
||||
class CheckoutStart(EventViewMixin, CartDisplayMixin, EventLoginRequiredMixin, TemplateView):
|
||||
class CheckoutStart(EventViewMixin, EventLoginRequiredMixin, TemplateView):
|
||||
template_name = "pretixpresale/event/checkout_questions.html"
|
||||
|
||||
def get_success_url(self):
|
||||
@@ -183,11 +183,11 @@ class CheckoutStart(EventViewMixin, CartDisplayMixin, EventLoginRequiredMixin, T
|
||||
return ctx
|
||||
|
||||
|
||||
class PaymentDetails(EventViewMixin, CartDisplayMixin, EventLoginRequiredMixin, TemplateView):
|
||||
class PaymentDetails(EventViewMixin, EventLoginRequiredMixin, TemplateView):
|
||||
template_name = "pretixpresale/event/checkout_payment.html"
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('presale:event.index', kwargs={
|
||||
return reverse('presale:event.checkout.confirm', kwargs={
|
||||
'event': self.request.event.slug,
|
||||
'organizer': self.request.event.organizer.slug,
|
||||
})
|
||||
@@ -229,6 +229,7 @@ class PaymentDetails(EventViewMixin, CartDisplayMixin, EventLoginRequiredMixin,
|
||||
def post(self, request, *args, **kwargs):
|
||||
for p in self.provider_forms:
|
||||
if p['provider'].identifier == request.POST.get('payment', ''):
|
||||
request.session['payment'] = p['provider'].identifier
|
||||
total = self._total_order_value + p['provider'].calculate_fee(self._total_order_value)
|
||||
resp = p['provider'].checkout_prepare(request, total)
|
||||
if isinstance(resp, HttpResponse):
|
||||
@@ -242,3 +243,12 @@ class PaymentDetails(EventViewMixin, CartDisplayMixin, EventLoginRequiredMixin,
|
||||
ctx = super().get_context_data(**kwargs)
|
||||
ctx['providers'] = self.provider_forms
|
||||
return ctx
|
||||
|
||||
|
||||
class OrderConfirm(EventViewMixin, CartDisplayMixin, EventLoginRequiredMixin, TemplateView):
|
||||
template_name = "pretixpresale/event/checkout_confirm.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
ctx = super().get_context_data(**kwargs)
|
||||
ctx['cart'] = self.get_cart()
|
||||
return ctx
|
||||
|
||||
Reference in New Issue
Block a user