forked from CGM_Public/pretix_original
View structure for adding items to cart
This commit is contained in:
@@ -155,6 +155,14 @@ DEFAULT_CURRENCY = 'EUR'
|
|||||||
|
|
||||||
INTERNAL_IPS = ('127.0.0.1', '::1')
|
INTERNAL_IPS = ('127.0.0.1', '::1')
|
||||||
|
|
||||||
|
from django.contrib.messages import constants as messages # NOQA
|
||||||
|
MESSAGE_TAGS = {
|
||||||
|
messages.INFO: 'alert-info',
|
||||||
|
messages.ERROR: 'alert-danger',
|
||||||
|
messages.WARNING: 'alert-warning',
|
||||||
|
messages.SUCCESS: 'alert-success',
|
||||||
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from local_settings import * # NOQA
|
from local_settings import * # NOQA
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|||||||
@@ -17,6 +17,13 @@
|
|||||||
<body>
|
<body>
|
||||||
<div class="container event">
|
<div class="container event">
|
||||||
<h1>{{ event.name }} <small>{{ event.date_from|date }}{% if event.show_date_to %} – {{ event.date_to|date }}{% endif %}</small></h1>
|
<h1>{{ event.name }} <small>{{ event.date_from|date }}{% if event.show_date_to %} – {{ event.date_to|date }}{% endif %}</small></h1>
|
||||||
|
{% if messages %}
|
||||||
|
{% for message in messages %}
|
||||||
|
<div class="alert {{ message.tags }}">
|
||||||
|
{{ message }}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,76 +2,81 @@
|
|||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% for tup in items_by_category %}
|
<form method="post"
|
||||||
<section>
|
action="{% url "presale:event.cart.add" organizer=request.event.organizer.slug event=request.event.slug %}?next={{ request.path_info|urlencode }}">
|
||||||
<h3>{{ tup.0.name }}</h3>
|
{% csrf_token %}
|
||||||
{% for item in tup.1 %}
|
{% for tup in items_by_category %}
|
||||||
{% if item.has_variations %}
|
<section>
|
||||||
<div class="row-fluid product-row headline">
|
<h3>{{ tup.0.name }}</h3>
|
||||||
<div class="col-md-8 col-xs-12">
|
{% for item in tup.1 %}
|
||||||
<strong>{{ item.name }}</strong>
|
{% if item.has_variations %}
|
||||||
{% if item.short_description %}<p>{{ item.short_description }}</p>{% endif %}
|
<div class="row-fluid product-row headline">
|
||||||
</div>
|
|
||||||
<div class="clearfix"></div>
|
|
||||||
</div>
|
|
||||||
{% for var in item.available_variations %}
|
|
||||||
<div class="row-fluid product-row variation">
|
|
||||||
<div class="col-md-8 col-xs-12">
|
<div class="col-md-8 col-xs-12">
|
||||||
{{ var }}
|
<strong>{{ item.name }}</strong>
|
||||||
|
{% if item.short_description %}<p>{{ item.short_description }}</p>{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
</div>
|
||||||
|
{% for var in item.available_variations %}
|
||||||
|
<div class="row-fluid product-row variation">
|
||||||
|
<div class="col-md-8 col-xs-12">
|
||||||
|
{{ var }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-2 col-xs-6 price">
|
||||||
|
{{ event.currency }} {{ var.price|floatformat:2 }}
|
||||||
|
{% if item.tax_rate %}
|
||||||
|
<br /><small>{% blocktrans trimmed with rate=item.tax_rate %}
|
||||||
|
incl. {{ rate }}% taxes
|
||||||
|
{% endblocktrans %}</small>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% if var.cached_availability.0 == 100 %}
|
||||||
|
<div class="col-md-2 col-xs-6 availability-box available">
|
||||||
|
<input type="number" class="form-control input-item-count" placeholder="0" min="0"
|
||||||
|
max="{{ var.cached_availability.1 }}"
|
||||||
|
name="variation_{{ var.variation.identity }}">
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
{% include "pretixpresale/event/fragment_availability.html" with avail=var.cached_availability.0 %}
|
||||||
|
{% endif %}
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
<div class="row-fluid product-row simple">
|
||||||
|
<div class="col-md-8 col-xs-12">
|
||||||
|
<strong>{{ item.name }}</strong>
|
||||||
|
{% if item.short_description %}<p>{{ item.short_description }}</p>{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2 col-xs-6 price">
|
<div class="col-md-2 col-xs-6 price">
|
||||||
{{ event.currency }} {{ var.price|floatformat:2 }}
|
{{ event.currency }} {{ item.price|floatformat:2 }}
|
||||||
{% if item.tax_rate %}
|
{% if item.tax_rate %}
|
||||||
<br /><small>{% blocktrans trimmed with rate=item.tax_rate %}
|
<br /><small>{% blocktrans trimmed with rate=item.tax_rate %}
|
||||||
incl. {{ rate }}% taxes
|
incl. {{ rate }}% taxes
|
||||||
{% endblocktrans %}</small>
|
{% endblocktrans %}</small>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% if var.cached_availability.0 == 100 %}
|
{% if item.cached_availability.0 == 100 %}
|
||||||
<div class="col-md-2 col-xs-6 availability-box available">
|
<div class="col-md-2 col-xs-6 availability-box available">
|
||||||
<input type="number" class="form-control input-item-count" placeholder="0" min="0"
|
<input type="number" class="form-control input-item-count" placeholder="0" min="0"
|
||||||
max="{{ var.cached_availability.1 }}">
|
max="{{ item.cached_availability.1 }}" name="item_{{ item.identity }}">
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% include "pretixpresale/event/fragment_availability.html" with avail=var.cached_availability.0 %}
|
{% include "pretixpresale/event/fragment_availability.html" with avail=item.cached_availability.0 %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endif %}
|
||||||
{% else %}
|
{% endfor %}
|
||||||
<div class="row-fluid product-row simple">
|
</section>
|
||||||
<div class="col-md-8 col-xs-12">
|
{% endfor %}
|
||||||
<strong>{{ item.name }}</strong>
|
<div class="row-fluid checkout-button-row">
|
||||||
{% if item.short_description %}<p>{{ item.short_description }}</p>{% endif %}
|
<div class="col-md-4 col-md-offset-8">
|
||||||
</div>
|
<button class="btn btn-block btn-primary btn-lg">
|
||||||
<div class="col-md-2 col-xs-6 price">
|
<i class="fa fa-shopping-cart"></i> {% trans "Add to cart" %}
|
||||||
{{ event.currency }} {{ item.price|floatformat:2 }}
|
</button>
|
||||||
{% if item.tax_rate %}
|
</div>
|
||||||
<br /><small>{% blocktrans trimmed with rate=item.tax_rate %}
|
<div class="clearfix"></div>
|
||||||
incl. {{ rate }}% taxes
|
|
||||||
{% endblocktrans %}</small>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
{% if item.cached_availability.0 == 100 %}
|
|
||||||
<div class="col-md-2 col-xs-6 availability-box available">
|
|
||||||
<input type="number" class="form-control input-item-count" placeholder="0" min="0"
|
|
||||||
max="{{ item.cached_availability.1 }}">
|
|
||||||
</div>
|
|
||||||
{% else %}
|
|
||||||
{% include "pretixpresale/event/fragment_availability.html" with avail=item.cached_availability.0 %}
|
|
||||||
{% endif %}
|
|
||||||
<div class="clearfix"></div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</section>
|
|
||||||
{% endfor %}
|
|
||||||
<div class="row-fluid checkout-button-row">
|
|
||||||
<div class="col-md-4 col-md-offset-8">
|
|
||||||
<button class="btn btn-block btn-primary btn-lg">
|
|
||||||
<i class="fa fa-shopping-cart"></i> {% trans "Proceed with checkout" %}
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="clearfix"></div>
|
</form>
|
||||||
</div>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -1,14 +1,15 @@
|
|||||||
from django.conf.urls import patterns, url, include
|
from django.conf.urls import patterns, url, include
|
||||||
|
|
||||||
import pretixpresale.views.event
|
import pretixpresale.views.event
|
||||||
|
import pretixpresale.views.cart
|
||||||
|
|
||||||
urlpatterns = patterns('',)
|
urlpatterns = patterns(
|
||||||
urlpatterns += patterns(
|
'',
|
||||||
'pretixpresale.views.event',
|
|
||||||
url(r'^(?P<organizer>[^/]+)/(?P<event>[^/]+)/', include(
|
url(r'^(?P<organizer>[^/]+)/(?P<event>[^/]+)/', include(
|
||||||
patterns(
|
patterns(
|
||||||
'pretixpresale.views',
|
'pretixpresale.views.event',
|
||||||
url(r'^$', pretixpresale.views.event.EventIndex.as_view(), name='event.index'),
|
url(r'^$', pretixpresale.views.event.EventIndex.as_view(), name='event.index'),
|
||||||
|
url(r'^cart/add$', pretixpresale.views.cart.CartAdd.as_view(), name='event.cart.add'),
|
||||||
)
|
)
|
||||||
))
|
)),
|
||||||
)
|
)
|
||||||
|
|||||||
27
src/pretixpresale/views/cart.py
Normal file
27
src/pretixpresale/views/cart.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
from django.contrib import messages
|
||||||
|
from django.core.urlresolvers import reverse
|
||||||
|
from django.shortcuts import redirect
|
||||||
|
from django.views.generic import View
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
from .event import EventViewMixin
|
||||||
|
|
||||||
|
|
||||||
|
class CartActionMixin:
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
if "next" in self.request.GET and '://' not in self.request.GET:
|
||||||
|
return self.request.GET.get('next')
|
||||||
|
else:
|
||||||
|
return reverse('presale:event.index', kwargs={
|
||||||
|
'event': self.request.event.slug,
|
||||||
|
'organizer': self.request.event.organizer.slug,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
class CartAdd(EventViewMixin, CartActionMixin, View):
|
||||||
|
|
||||||
|
def post(self, *args, **kwargs):
|
||||||
|
messages.error(self.request, _('Cart is not yet implemented'))
|
||||||
|
print("hi")
|
||||||
|
return redirect(self.get_success_url())
|
||||||
Reference in New Issue
Block a user