mirror of
https://github.com/pretix/pretix.git
synced 2026-04-26 23:52:35 +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):
|
class OrganizerSettingsSerializer(SettingsSerializer):
|
||||||
default_fields = [
|
default_fields = [
|
||||||
'customer_accounts',
|
'customer_accounts',
|
||||||
|
'customer_accounts_link_by_email',
|
||||||
'contact_mail',
|
'contact_mail',
|
||||||
'imprint_url',
|
'imprint_url',
|
||||||
'organizer_info_text',
|
'organizer_info_text',
|
||||||
|
|||||||
@@ -118,6 +118,17 @@ DEFAULTS = {
|
|||||||
"advanced features like memberships.")
|
"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': {
|
'max_items_per_order': {
|
||||||
'default': '10',
|
'default': '10',
|
||||||
'type': int,
|
'type': int,
|
||||||
|
|||||||
@@ -285,6 +285,7 @@ class OrganizerSettingsForm(SettingsForm):
|
|||||||
)
|
)
|
||||||
auto_fields = [
|
auto_fields = [
|
||||||
'customer_accounts',
|
'customer_accounts',
|
||||||
|
'customer_accounts_link_by_email',
|
||||||
'contact_mail',
|
'contact_mail',
|
||||||
'imprint_url',
|
'imprint_url',
|
||||||
'organizer_info_text',
|
'organizer_info_text',
|
||||||
|
|||||||
@@ -55,6 +55,7 @@
|
|||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>{% trans "Customer accounts" %}</legend>
|
<legend>{% trans "Customer accounts" %}</legend>
|
||||||
{% bootstrap_field sform.customer_accounts layout="control" %}
|
{% 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 layout="control" %}
|
||||||
{% bootstrap_field sform.name_scheme_titles layout="control" %}
|
{% bootstrap_field sform.name_scheme_titles layout="control" %}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|||||||
@@ -1747,9 +1747,12 @@ class CustomerDetailView(OrganizerDetailViewMixin, OrganizerPermissionRequiredMi
|
|||||||
context_object_name = 'orders'
|
context_object_name = 'orders'
|
||||||
|
|
||||||
def get_queryset(self):
|
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(
|
qs = Order.objects.filter(
|
||||||
Q(customer=self.customer)
|
q
|
||||||
| Q(email__iexact=self.customer.email)
|
|
||||||
).select_related('event').order_by('-datetime')
|
).select_related('event').order_by('-datetime')
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
|
|||||||
@@ -277,10 +277,12 @@ class ProfileView(CustomerRequiredMixin, ListView):
|
|||||||
paginate_by = 20
|
paginate_by = 20
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
qs = Order.objects.filter(
|
q = Q(customer=self.request.customer)
|
||||||
Q(customer=self.request.customer)
|
if self.request.organizer.settings.customer_accounts_link_by_email:
|
||||||
| Q(email__iexact=self.request.customer.email)
|
|
||||||
# This is safe because we only let customers with verified emails log in
|
# 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')
|
).select_related('event').order_by('-datetime')
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user