Do not create duplicate memberships on order changes (Z#23163336) (#4408)

This commit is contained in:
Raphael Michel
2024-08-21 17:30:42 +02:00
committed by GitHub
parent eb2ad48089
commit b96374fcf6
4 changed files with 46 additions and 3 deletions

View File

@@ -151,6 +151,12 @@
</div>
<div class="col-sm-4">
{% bootstrap_field position.form.itemvar layout='inline' %}
{% if position.granted_memberships.all %}
<span class="text-muted">
<span class="fa fa-warning text-warning" aria-hidden="true"></span>
{% trans "The sale of this position created a membership. Changing the product here will not affect the membership. Memberships can be managed in the customer account." %}
</span>
{% endif %}
</div>
</div>
@@ -254,6 +260,12 @@
{% trans "" %}
</div>
{% bootstrap_field position.form.valid_until layout='inline' %}
{% if position.granted_memberships.all %}
<span class="text-muted">
<span class="fa fa-warning text-warning" aria-hidden="true"></span>
{% trans "The sale of this position created a membership. Changing the validity of the ticket here will not affect the membership. Memberships can be managed in the customer account." %}
</span>
{% endif %}
</div>
</div>

View File

@@ -1900,7 +1900,7 @@ class OrderChange(OrderView):
positions = list(self.order.positions.select_related(
'item', 'item__tax_rule', 'used_membership', 'used_membership__membership_type', 'tax_rule',
'seat', 'subevent',
))
).prefetch_related('granted_memberships'))
for p in positions:
p.form = OrderPositionChangeForm(prefix='op-{}'.format(p.pk), instance=p, items=self.items,
initial={'seat': p.seat.seat_guid if p.seat else None},