mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Allow attendees to change selected add-ons of same price (#3150)
This commit is contained in:
@@ -2555,6 +2555,27 @@ class OrderPosition(AbstractPosition):
|
||||
attach_tickets=True
|
||||
)
|
||||
|
||||
@property
|
||||
@scopes_disabled()
|
||||
def attendee_change_allowed(self) -> bool:
|
||||
"""
|
||||
Returns whether or not this order can be changed by the attendee.
|
||||
"""
|
||||
from .items import ItemAddOn
|
||||
|
||||
if not self.event.settings.change_allow_attendee or not self.order.user_change_allowed:
|
||||
return False
|
||||
|
||||
positions = list(
|
||||
self.order.positions.filter(Q(pk=self.pk) | Q(addon_to_id=self.pk)).annotate(
|
||||
has_variations=Exists(ItemVariation.objects.filter(item_id=OuterRef('item_id'))),
|
||||
).select_related('item').prefetch_related('issued_gift_cards')
|
||||
)
|
||||
return (
|
||||
(self.order.event.settings.change_allow_user_variation and any([op.has_variations for op in positions])) or
|
||||
(self.order.event.settings.change_allow_user_addons and ItemAddOn.objects.filter(base_item_id__in=[op.item_id for op in positions]).exists())
|
||||
)
|
||||
|
||||
|
||||
class Transaction(models.Model):
|
||||
"""
|
||||
|
||||
@@ -1484,6 +1484,19 @@ DEFAULTS = {
|
||||
label=_("Do not allow changes after"),
|
||||
)
|
||||
},
|
||||
'change_allow_attendee': {
|
||||
'default': 'False',
|
||||
'type': bool,
|
||||
'form_class': forms.BooleanField,
|
||||
'serializer_class': serializers.BooleanField,
|
||||
'form_kwargs': dict(
|
||||
label=_("Allow individual attendees to change their ticket"),
|
||||
help_text=_("By default, only the person who ordered the tickets can make any changes. If you check this "
|
||||
"box, individual attendees can also make changes. However, individual attendees can always "
|
||||
"only make changes that do not change the total price of the order. Such changes can always "
|
||||
"only be made by the main customer."),
|
||||
)
|
||||
},
|
||||
'cancel_allow_user': {
|
||||
'default': 'True',
|
||||
'type': bool,
|
||||
|
||||
Reference in New Issue
Block a user