mirror of
https://github.com/pretix/pretix.git
synced 2026-02-09 03:12:25 +00:00
Customer accounts: Only link orders by email if wanted
This commit is contained in:
@@ -273,6 +273,7 @@ class TeamMemberSerializer(serializers.ModelSerializer):
|
||||
class OrganizerSettingsSerializer(SettingsSerializer):
|
||||
default_fields = [
|
||||
'customer_accounts',
|
||||
'customer_accounts_link_by_email',
|
||||
'contact_mail',
|
||||
'imprint_url',
|
||||
'organizer_info_text',
|
||||
|
||||
@@ -118,6 +118,17 @@ DEFAULTS = {
|
||||
"advanced features like memberships.")
|
||||
)
|
||||
},
|
||||
'customer_accounts_link_by_email': {
|
||||
'default': 'False',
|
||||
'type': bool,
|
||||
'form_class': forms.BooleanField,
|
||||
'serializer_class': serializers.BooleanField,
|
||||
'form_kwargs': dict(
|
||||
label=_("Match orders based on email address"),
|
||||
help_text=_("This will allow registered customers to access orders made with the same email address, even if the customer "
|
||||
"was not logged in during the purchase.")
|
||||
)
|
||||
},
|
||||
'max_items_per_order': {
|
||||
'default': '10',
|
||||
'type': int,
|
||||
|
||||
@@ -285,6 +285,7 @@ class OrganizerSettingsForm(SettingsForm):
|
||||
)
|
||||
auto_fields = [
|
||||
'customer_accounts',
|
||||
'customer_accounts_link_by_email',
|
||||
'contact_mail',
|
||||
'imprint_url',
|
||||
'organizer_info_text',
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
<fieldset>
|
||||
<legend>{% trans "Customer accounts" %}</legend>
|
||||
{% bootstrap_field sform.customer_accounts layout="control" %}
|
||||
{% bootstrap_field sform.customer_accounts_link_by_email layout="control" %}
|
||||
{% bootstrap_field sform.name_scheme layout="control" %}
|
||||
{% bootstrap_field sform.name_scheme_titles layout="control" %}
|
||||
</fieldset>
|
||||
|
||||
@@ -1747,9 +1747,12 @@ class CustomerDetailView(OrganizerDetailViewMixin, OrganizerPermissionRequiredMi
|
||||
context_object_name = 'orders'
|
||||
|
||||
def get_queryset(self):
|
||||
q = Q(customer=self.customer)
|
||||
if self.request.organizer.settings.customer_accounts_link_by_email:
|
||||
# This is safe because we only let customers with verified emails log in
|
||||
q |= Q(email__iexact=self.customer.email)
|
||||
qs = Order.objects.filter(
|
||||
Q(customer=self.customer)
|
||||
| Q(email__iexact=self.customer.email)
|
||||
q
|
||||
).select_related('event').order_by('-datetime')
|
||||
return qs
|
||||
|
||||
|
||||
@@ -277,10 +277,12 @@ class ProfileView(CustomerRequiredMixin, ListView):
|
||||
paginate_by = 20
|
||||
|
||||
def get_queryset(self):
|
||||
qs = Order.objects.filter(
|
||||
Q(customer=self.request.customer)
|
||||
| Q(email__iexact=self.request.customer.email)
|
||||
q = Q(customer=self.request.customer)
|
||||
if self.request.organizer.settings.customer_accounts_link_by_email:
|
||||
# This is safe because we only let customers with verified emails log in
|
||||
q |= Q(email__iexact=self.request.customer.email)
|
||||
qs = Order.objects.filter(
|
||||
q
|
||||
).select_related('event').order_by('-datetime')
|
||||
return qs
|
||||
|
||||
|
||||
Reference in New Issue
Block a user