mirror of
https://github.com/pretix/pretix.git
synced 2026-11-13 01:47:07 +00:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8287ba4275 | ||
|
|
35ebfa0d47 | ||
|
|
8563d5bb38 | ||
|
|
12a00967c6 | ||
|
|
dc36c0e891 |
No files matched your search
@@ -20,6 +20,7 @@
|
||||
# <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
import sys
|
||||
from collections import Counter
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
@@ -472,3 +473,11 @@ def _item_num_options(item):
|
||||
|
||||
def get_item_option_count(items):
|
||||
return sum(_item_num_options(item) for item in items)
|
||||
|
||||
|
||||
def get_item_var_sums(positions, subevent):
|
||||
itemvarsums = Counter()
|
||||
for pos in positions:
|
||||
if pos.subevent == subevent:
|
||||
itemvarsums[pos.variation or pos.item] += 1
|
||||
return itemvarsums
|
||||
@@ -125,10 +125,10 @@
|
||||
<div class="col-md-8 col-sm-6 col-xs-12">
|
||||
<h{{ headline_level|default:3|add:2 }} class="h5" id="{{ form_prefix }}item-{{ item.pk }}-{{ var.pk }}-legend">
|
||||
{{ var }}
|
||||
{% if cart.itemvarsums|getitem:var %}
|
||||
{% if itemvarsums|getitem:var %}
|
||||
<span class="textbubble-success">
|
||||
{% icon "shopping-cart" %}
|
||||
{% blocktrans trimmed count amount=cart.itemvarsums|getitem:var %}
|
||||
{% blocktrans trimmed count amount=itemvarsums|getitem:var %}
|
||||
{{ amount }}× in your cart
|
||||
{% plural %}
|
||||
{{ amount }}× in your cart
|
||||
@@ -299,10 +299,10 @@
|
||||
<div class="product-description {% if item.picture %}with-picture{% endif %}">
|
||||
<h{{ headline_level|default:3|add:1 }} class="h4" id="{{ form_prefix }}item-{{ item.pk }}-legend">
|
||||
{{ item.name }}
|
||||
{% if cart.itemvarsums|getitem:item %}
|
||||
{% if itemvarsums|getitem:item %}
|
||||
<span class="textbubble-success">
|
||||
{% icon "shopping-cart" %}
|
||||
{% blocktrans trimmed count amount=cart.itemvarsums|getitem:item %}
|
||||
{% blocktrans trimmed count amount=itemvarsums|getitem:item %}
|
||||
{{ amount }}× in your cart
|
||||
{% plural %}
|
||||
{{ amount }}× in your cart
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
# License for the specific language governing permissions and limitations under the License.
|
||||
import copy
|
||||
import warnings
|
||||
from collections import Counter, defaultdict
|
||||
from collections import defaultdict
|
||||
from datetime import datetime, timedelta
|
||||
from decimal import Decimal
|
||||
from functools import wraps
|
||||
@@ -266,10 +266,6 @@ class CartMixin:
|
||||
minutes_left = None
|
||||
seconds_left = None
|
||||
|
||||
itemvarsums = Counter()
|
||||
for p in cartpos:
|
||||
itemvarsums[p.variation or p.item] += 1
|
||||
|
||||
return {
|
||||
'positions': positions,
|
||||
'invoice_address': self.invoice_address,
|
||||
@@ -291,7 +287,6 @@ class CartMixin:
|
||||
not self.request.event.settings.display_net_prices and
|
||||
sum(c.price_includes_rounding_correction for c in positions) + sum(f.price_includes_rounding_correction for f in fees)
|
||||
),
|
||||
'itemvarsums': itemvarsums,
|
||||
'current_selected_payments': [
|
||||
p for p in self.current_selected_payments(lcp, fees, self.invoice_address)
|
||||
if p.get('multi_use_supported')
|
||||
|
||||
@@ -70,7 +70,8 @@ from pretix.helpers.http import redirect_to_url
|
||||
from pretix.helpers.safedownload import check_token
|
||||
from pretix.multidomain.urlreverse import eventreverse
|
||||
from pretix.presale.productlist import (
|
||||
get_item_option_count, item_group_by_category, prepare_item_list_for_shop,
|
||||
get_item_option_count, get_item_var_sums, item_group_by_category,
|
||||
prepare_item_list_for_shop,
|
||||
)
|
||||
from pretix.presale.views import (
|
||||
CartMixin, EventViewMixin, allow_cors_if_namespaced,
|
||||
@@ -701,6 +702,7 @@ class RedeemView(NoSearchIndexViewMixin, EventViewMixin, CartMixin, TemplateView
|
||||
)
|
||||
|
||||
context['cart'] = self.get_cart()
|
||||
context['itemvarsums'] = get_item_var_sums(context['cart'].get('raw', []), self.subevent)
|
||||
context['show_cart'] = context['cart']['positions']
|
||||
|
||||
# Regroup those by category
|
||||
|
||||
@@ -72,7 +72,8 @@ from pretix.helpers.http import redirect_to_url
|
||||
from pretix.multidomain.urlreverse import eventreverse
|
||||
from pretix.presale.ical import get_public_ical
|
||||
from pretix.presale.productlist import (
|
||||
get_item_option_count, item_group_by_category, prepare_item_list_for_shop,
|
||||
get_item_option_count, get_item_var_sums, item_group_by_category,
|
||||
prepare_item_list_for_shop,
|
||||
)
|
||||
from pretix.presale.signals import seatingframe_html_head
|
||||
from pretix.presale.views.organizer import (
|
||||
@@ -244,6 +245,7 @@ class EventIndex(EventViewMixin, EventListMixin, CartMixin, TemplateView):
|
||||
context['display_add_to_cart'] = display_add_to_cart
|
||||
|
||||
context['cart'] = self.get_cart()
|
||||
context['itemvarsums'] = get_item_var_sums(context['cart'].get('raw', []), self.subevent)
|
||||
context['has_addon_choices'] = any(cp.has_addon_choices for cp in get_cart(self.request))
|
||||
|
||||
templating_context = PlaceholderContext(event_or_subevent=self.subevent or self.request.event, event=self.request.event)
|
||||
|
||||
Reference in new issue
Block a user