Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/eventyay/base/configurations/default_setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,15 @@ def primary_font_kwargs():
help_text=_('Require attendees to enter their primary email address twice to help prevent errors.'),
),
},
'include_wikimedia_username': {
'default': 'False',
'type': bool,
'form_class': forms.BooleanField,
'serializer_class': serializers.BooleanField,
'form_kwargs': dict(
label=_('Add the Wikimedia ID for users authenticated via Wikimedia'),
),
},
'order_phone_asked': {
'default': 'False',
'type': bool,
Expand Down
25 changes: 25 additions & 0 deletions app/eventyay/base/exporters/orderlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
Order,
OrderPosition,
Question,
User,
)
from eventyay.base.models.orders import OrderFee, OrderPayment, OrderRefund
from eventyay.base.services.quotas import QuotaAvailability
Expand Down Expand Up @@ -277,13 +278,20 @@ def iterate_orders(self, form_data: dict):
.annotate(k=Count('id'))
.values('k')
)

# Always load wikimedia_username (lightweight data)
wikimedia_query = User.objects.filter(
email=OuterRef('email')
).values('wikimedia_username')[:1]

qs = (
Order.objects.filter(event__in=self.events)
.annotate(
payment_date=Subquery(p_date, output_field=DateTimeField()),
payment_providers=Subquery(p_providers, output_field=CharField()),
invoice_numbers=Subquery(i_numbers, output_field=CharField()),
pcnt=Subquery(s, output_field=IntegerField()),
wikimedia_username=Subquery(wikimedia_query, output_field=CharField()),
)
.select_related('invoice_address')
)
Expand All @@ -294,6 +302,12 @@ def iterate_orders(self, form_data: dict):
qs = qs.filter(status=Order.STATUS_PAID)
tax_rates = self._get_all_tax_rates(qs)

# Check if we need to include wikimedia_username in the export
should_include_wikimedia = any(
self.event_object_cache[event_id].settings.get('include_wikimedia_username', False)
for event_id in self.event_object_cache.keys()
)

headers = [
_('Event slug'),
_('Order code'),
Expand All @@ -306,6 +320,11 @@ def iterate_orders(self, form_data: dict):
_('Company'),
_('Name'),
]

# Add wikimedia_username header if setting is enabled
if should_include_wikimedia:
headers.insert(headers.index(_('Phone number')), _('Wikimedia username'))

name_scheme = PERSON_NAME_SCHEMES[self.event.settings.name_scheme] if not self.is_multievent else None
if name_scheme and len(name_scheme['fields']) > 1:
for k, label, w in name_scheme['fields']:
Expand Down Expand Up @@ -398,6 +417,12 @@ def iterate_orders(self, form_data: dict):
order.datetime.astimezone(tz).strftime('%Y-%m-%d'),
order.datetime.astimezone(tz).strftime('%H:%M:%S %Z'),
]

# Add wikimedia_username if setting is enabled (insert before phone number)
if should_include_wikimedia:
wikimedia_username = getattr(order, 'wikimedia_username', '') or ''
row.insert(5, wikimedia_username)

try:
row += [
order.invoice_address.company,
Expand Down
15 changes: 8 additions & 7 deletions app/eventyay/control/forms/event.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from urllib.parse import urlencode, urlparse
from urllib.parse import urlencode

from django import forms
from django.conf import settings
Expand All @@ -7,9 +7,9 @@
from django.db.models import Q
from django.forms import CheckboxSelectMultiple, formset_factory
from django.urls import reverse
from django.utils.crypto import get_random_string
from django.utils.html import escape
from django.utils.safestring import mark_safe
from django.utils.crypto import get_random_string
from django.utils.timezone import get_current_timezone_name
from django.utils.translation import gettext, pgettext_lazy
from django.utils.translation import gettext_lazy as _
Expand Down Expand Up @@ -78,7 +78,7 @@ def __init__(self, *args, **kwargs):
# Make organizer required only if more than one exists
organizer_count = qs.count()
is_required = organizer_count > 1

self.fields['organizer'] = forms.ModelChoiceField(
label=_('Organizer'),
queryset=qs,
Expand Down Expand Up @@ -176,11 +176,11 @@ def __init__(self, *args, **kwargs):
self.fields['location'].widget.attrs['rows'] = '3'
self.fields['location'].widget.attrs['placeholder'] = _('Sample Conference Center\nHeidelberg, Germany')
self.fields['slug'].widget.prefix = build_absolute_uri(self.organizer, 'presale:organizer.index')

# Generate a unique slug if none provided
if not self.initial.get('slug'):
charset = list('abcdefghjklmnpqrstuvwxyz3789')

# Try different lengths until we find a unique slug
length = 6
counter = 0
Expand All @@ -192,11 +192,11 @@ def __init__(self, *args, **kwargs):
# Fallback: add counter to ensure uniqueness
candidate = f'{get_random_string(length=4, allowed_chars=charset)}{counter}'
counter += 1

if not self.organizer.events.filter(slug__iexact=candidate).exists():
self.initial['slug'] = candidate
break

if self.has_subevents:
del self.fields['presale_start']
del self.fields['presale_end']
Expand Down Expand Up @@ -549,6 +549,7 @@ class EventSettingsForm(SettingsForm):
'banner_text',
'banner_text_bottom',
'order_email_asked_twice',
'include_wikimedia_username',
'allow_modifications',
'last_order_modification_date',
'allow_modifications_after_checkin',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ <h4>{% trans "Customer data (once per order)" %}</h4>
</div>
</div>
{% bootstrap_field sform.order_email_asked_twice layout="control" %}
{% bootstrap_field sform.include_wikimedia_username layout="control" %}
{% bootstrap_field sform.order_phone_asked_required layout="control" %}
<div class="form-group">
<label class="control-label col-md-3">
Expand Down Expand Up @@ -101,7 +102,7 @@ <h4>{% trans "Other settings" %}</h4>
{% bootstrap_field sform.name_scheme layout="control" %}
{% bootstrap_field sform.name_scheme_titles layout="control" %}
{% bootstrap_field sform.checkout_show_copy_answers_button layout="control" %}

<h4>{% translate "Changes to existing orders" %}</h4>
{% bootstrap_field sform.allow_modifications layout="control" %}
<div data-display-dependency='#id_settings-allow_modifications_0' data-inverse>
Expand Down Expand Up @@ -190,7 +191,7 @@ <h4>{% translate "Changes to existing orders" %}</h4>
{% bootstrap_field sform.banner_text_bottom layout="control" %}
{% bootstrap_field sform.event_info_text layout="control" %}
</fieldset>


<fieldset>
<legend>{% trans "Timeline" %}</legend>
Expand Down
4 changes: 2 additions & 2 deletions app/eventyay/control/views/orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@
Checkin,
Invoice,
InvoiceAddress,
Product,
ProductVariation,
LogEntry,
Order,
Product,
ProductVariation,
QuestionAnswer,
Quota,
generate_secret,
Expand Down
Loading