Customer accounts: Only link orders by email if wanted

This commit is contained in:
Raphael Michel
2021-05-25 15:09:35 +02:00
parent 538dd933fb
commit ea514948b5
6 changed files with 24 additions and 5 deletions

View File

@@ -285,6 +285,7 @@ class OrganizerSettingsForm(SettingsForm):
)
auto_fields = [
'customer_accounts',
'customer_accounts_link_by_email',
'contact_mail',
'imprint_url',
'organizer_info_text',

View File

@@ -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>

View File

@@ -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