mirror of
https://github.com/pretix/pretix.git
synced 2026-05-20 17:44:02 +00:00
CartManager: expect reservation_time parameter instead of expiry date
This commit is contained in:
@@ -33,6 +33,7 @@
|
|||||||
# License for the specific language governing permissions and limitations under the License.
|
# License for the specific language governing permissions and limitations under the License.
|
||||||
import re
|
import re
|
||||||
import uuid
|
import uuid
|
||||||
|
import warnings
|
||||||
from collections import Counter, defaultdict, namedtuple
|
from collections import Counter, defaultdict, namedtuple
|
||||||
from datetime import datetime, time, timedelta
|
from datetime import datetime, time, timedelta
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
@@ -275,7 +276,10 @@ class CartManager:
|
|||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, event: Event, cart_id: str, sales_channel: SalesChannel,
|
def __init__(self, event: Event, cart_id: str, sales_channel: SalesChannel,
|
||||||
invoice_address: InvoiceAddress=None, widget_data=None, expiry=None):
|
invoice_address: InvoiceAddress=None, widget_data=None, expiry=None, reservation_time: timedelta=None):
|
||||||
|
"""
|
||||||
|
Creates a new CartManager for an event.
|
||||||
|
"""
|
||||||
self.event = event
|
self.event = event
|
||||||
self.cart_id = cart_id
|
self.cart_id = cart_id
|
||||||
self.real_now_dt = now()
|
self.real_now_dt = now()
|
||||||
@@ -286,12 +290,21 @@ class CartManager:
|
|||||||
self._subevents_cache = {}
|
self._subevents_cache = {}
|
||||||
self._variations_cache = {}
|
self._variations_cache = {}
|
||||||
self._seated_cache = {}
|
self._seated_cache = {}
|
||||||
self._expiry = None
|
|
||||||
self._explicit_expiry = expiry
|
|
||||||
self.invoice_address = invoice_address
|
self.invoice_address = invoice_address
|
||||||
self._widget_data = widget_data or {}
|
self._widget_data = widget_data or {}
|
||||||
self._sales_channel = sales_channel
|
self._sales_channel = sales_channel
|
||||||
|
|
||||||
|
if expiry and reservation_time:
|
||||||
|
raise TypeError('Cannot specify both expiry and reservation_time')
|
||||||
|
elif expiry:
|
||||||
|
warnings.warn('CartManager(expiry=...) is deprecated, use reservation_time=... instead')
|
||||||
|
self._reservation_time = expiry - now()
|
||||||
|
elif reservation_time:
|
||||||
|
self._reservation_time = reservation_time
|
||||||
|
else:
|
||||||
|
self._reservation_time = timedelta(minutes=self.event.settings.get('reservation_time', as_type=int))
|
||||||
|
self._expiry = self.real_now_dt + self._reservation_time
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def positions(self):
|
def positions(self):
|
||||||
return self.event.cartposition_set.filter(
|
return self.event.cartposition_set.filter(
|
||||||
@@ -1416,7 +1429,6 @@ class CartManager:
|
|||||||
def commit(self):
|
def commit(self):
|
||||||
self._check_presale_dates()
|
self._check_presale_dates()
|
||||||
self._check_max_cart_size()
|
self._check_max_cart_size()
|
||||||
self._calculate_expiry()
|
|
||||||
|
|
||||||
err = self._delete_out_of_timeframe()
|
err = self._delete_out_of_timeframe()
|
||||||
err = self.extend_expired_positions() or err
|
err = self.extend_expired_positions() or err
|
||||||
|
|||||||
Reference in New Issue
Block a user