forked from CGM_Public/pretix_original
Merge pull request 'upstream/2025.3.0' (#3) from upstream/2025.3.0 into master
All checks were successful
Build Deploy email notification tool / Apply-Kubernetes-Resources (push) Successful in 9s
All checks were successful
Build Deploy email notification tool / Apply-Kubernetes-Resources (push) Successful in 9s
Reviewed-on: simon/pretix_cgo#3
This commit is contained in:
@@ -83,8 +83,8 @@ from pretix.base.services.tax import (
|
||||
VATIDFinalError, VATIDTemporaryError, validate_vat_id,
|
||||
)
|
||||
from pretix.base.settings import (
|
||||
COUNTRIES_WITH_STATE_IN_ADDRESS, PERSON_NAME_SALUTATIONS,
|
||||
PERSON_NAME_SCHEMES, PERSON_NAME_TITLE_GROUPS,
|
||||
COUNTRIES_WITH_STATE_IN_ADDRESS, COUNTRY_STATE_LABEL,
|
||||
PERSON_NAME_SALUTATIONS, PERSON_NAME_SCHEMES, PERSON_NAME_TITLE_GROUPS,
|
||||
)
|
||||
from pretix.base.templatetags.rich_text import rich_text
|
||||
from pretix.base.timemachine import time_machine_now
|
||||
@@ -721,7 +721,7 @@ class BaseQuestionsForm(forms.Form):
|
||||
'data-country-information-url': reverse('js_helpers.states'),
|
||||
}),
|
||||
)
|
||||
c = [('', pgettext_lazy('address', 'Select state'))]
|
||||
c = [('', '---')]
|
||||
fprefix = str(self.prefix) + '-' if self.prefix is not None and self.prefix != '-' else ''
|
||||
cc = None
|
||||
state = None
|
||||
@@ -1079,7 +1079,7 @@ class BaseInvoiceAddressForm(forms.ModelForm):
|
||||
self.fields['country'].choices = CachedCountries()
|
||||
self.fields['country'].widget.attrs['data-country-information-url'] = reverse('js_helpers.states')
|
||||
|
||||
c = [('', pgettext_lazy('address', 'Select state'))]
|
||||
c = [('', '---')]
|
||||
fprefix = self.prefix + '-' if self.prefix else ''
|
||||
cc = None
|
||||
if fprefix + 'country' in self.data:
|
||||
@@ -1088,16 +1088,19 @@ class BaseInvoiceAddressForm(forms.ModelForm):
|
||||
cc = str(self.initial['country'])
|
||||
elif self.instance and self.instance.country:
|
||||
cc = str(self.instance.country)
|
||||
state_label = pgettext_lazy('address', 'State')
|
||||
if cc and cc in COUNTRIES_WITH_STATE_IN_ADDRESS:
|
||||
types, form = COUNTRIES_WITH_STATE_IN_ADDRESS[cc]
|
||||
statelist = [s for s in pycountry.subdivisions.get(country_code=cc) if s.type in types]
|
||||
c += sorted([(s.code[3:], s.name) for s in statelist], key=lambda s: s[1])
|
||||
if cc in COUNTRY_STATE_LABEL:
|
||||
state_label = COUNTRY_STATE_LABEL[cc]
|
||||
elif fprefix + 'state' in self.data:
|
||||
self.data = self.data.copy()
|
||||
del self.data[fprefix + 'state']
|
||||
|
||||
self.fields['state'] = forms.ChoiceField(
|
||||
label=pgettext_lazy('address', 'State'),
|
||||
label=state_label,
|
||||
required=False,
|
||||
choices=c,
|
||||
widget=forms.Select(attrs={
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
# Generated by Django 4.2.16 on 2025-02-28 13:25
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def remove_duplicates(apps, schema_editor):
|
||||
UserKnownLoginSource = apps.get_model("pretixbase", "UserKnownLoginSource")
|
||||
unique_fields = ["user", "agent_type", "device_type", "os_type", "country"]
|
||||
|
||||
duplicates = (
|
||||
UserKnownLoginSource.objects
|
||||
.values(*unique_fields)
|
||||
.order_by()
|
||||
.annotate(latest_id=models.Max('id'), count=models.Count('id'))
|
||||
.filter(count__gt=1)
|
||||
)
|
||||
|
||||
for duplicate in duplicates:
|
||||
(
|
||||
UserKnownLoginSource.objects
|
||||
.filter(**{x: duplicate[x] for x in unique_fields})
|
||||
.exclude(id=duplicate["latest_id"])
|
||||
.delete()
|
||||
)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("pretixbase", "0277_customerssoclient_require_pkce_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(remove_duplicates, migrations.RunPython.noop),
|
||||
migrations.AlterUniqueTogether(
|
||||
name="userknownloginsource",
|
||||
unique_together={
|
||||
("user", "agent_type", "device_type", "os_type", "country")
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -602,6 +602,9 @@ class UserKnownLoginSource(models.Model):
|
||||
country = FastCountryField(null=True, blank=True)
|
||||
last_seen = models.DateTimeField()
|
||||
|
||||
class Meta:
|
||||
unique_together = ('user', 'agent_type', 'device_type', 'os_type', 'country')
|
||||
|
||||
|
||||
class StaffSession(models.Model):
|
||||
user = models.ForeignKey('User', on_delete=models.PROTECT)
|
||||
|
||||
@@ -60,6 +60,7 @@ from django.urls import reverse
|
||||
from django.utils.crypto import get_random_string
|
||||
from django.utils.formats import date_format
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.html import format_html
|
||||
from django.utils.timezone import make_aware, now
|
||||
from django.utils.translation import gettext, gettext_lazy as _
|
||||
from django_scopes import ScopedManager, scopes_disabled
|
||||
@@ -171,7 +172,7 @@ class EventMixin:
|
||||
self.date_to.astimezone(tz), ("D" if short else "l")
|
||||
)
|
||||
|
||||
def get_date_range_display(self, tz=None, force_show_end=False, as_html=False) -> str:
|
||||
def get_date_range_display(self, tz=None, force_show_end=False, as_html=False, try_to_show_times=False) -> str:
|
||||
"""
|
||||
Returns a formatted string containing the start date and the end date
|
||||
of the event with respect to the current locale and to the ``show_date_to``
|
||||
@@ -180,36 +181,48 @@ class EventMixin:
|
||||
tz = tz or self.timezone
|
||||
if (not self.settings.show_date_to and not force_show_end) or not self.date_to:
|
||||
df, dt = self.date_from, self.date_from
|
||||
show_times = try_to_show_times
|
||||
else:
|
||||
df, dt = self.date_from, self.date_to
|
||||
return daterange(df.astimezone(tz), dt.astimezone(tz), as_html)
|
||||
show_times = try_to_show_times and self.settings.show_times and (
|
||||
# Show times if start and end are on the same day ("08:00-10:00")
|
||||
dt.astimezone(tz).date() == df.astimezone(tz).date() or
|
||||
# Show times if start and end are on consecutive days and less than 24h ("23:00-03:00")
|
||||
(dt.astimezone(tz).date() == df.astimezone(tz).date() + timedelta(days=1) and
|
||||
dt.astimezone(tz).time() < df.astimezone(tz).time())
|
||||
)
|
||||
d = daterange(df.astimezone(tz), dt.astimezone(tz), as_html)
|
||||
|
||||
if show_times:
|
||||
if (not self.settings.show_date_to and not force_show_end) or not self.date_to:
|
||||
time_str = _date(self.date_from.astimezone(tz), "TIME_FORMAT")
|
||||
else:
|
||||
time_str = '{}–{}'.format(
|
||||
_date(self.date_from.astimezone(tz), "TIME_FORMAT"),
|
||||
_date(self.date_to.astimezone(tz), "TIME_FORMAT"),
|
||||
)
|
||||
|
||||
if as_html:
|
||||
d = format_html(
|
||||
d + ' <time datetime="{}" data-timezone="{}" data-time-short>{}</time>',
|
||||
self.date_from.isoformat(),
|
||||
str(self.timezone),
|
||||
time_str,
|
||||
)
|
||||
else:
|
||||
d = d + ' ' + time_str
|
||||
|
||||
return d
|
||||
|
||||
def get_date_range_display_with_times(self) -> str: # Helper for usage from templates
|
||||
return self.get_date_range_display(try_to_show_times=True)
|
||||
|
||||
def get_date_range_display_with_times_as_html(self) -> str: # Helper for usage from templates
|
||||
return self.get_date_range_display(try_to_show_times=True, as_html=True)
|
||||
|
||||
def get_date_range_display_as_html(self, tz=None, force_show_end=False) -> str:
|
||||
return self.get_date_range_display(tz, force_show_end, as_html=True)
|
||||
|
||||
def get_time_range_display(self, tz=None, force_show_end=False) -> str:
|
||||
"""
|
||||
Returns a formatted string containing the start time and sometimes the end time
|
||||
of the event with respect to the current locale and to the ``show_date_to``
|
||||
setting. Dates are not shown. This is usually used in combination with get_date_range_display
|
||||
"""
|
||||
tz = tz or self.timezone
|
||||
|
||||
show_date_to = self.date_to and (self.settings.show_date_to or force_show_end) and (
|
||||
# Show date to if start and end are on the same day ("08:00-10:00")
|
||||
self.date_to.astimezone(tz).date() == self.date_from.astimezone(tz).date() or
|
||||
# Show date to if start and end are on consecutive days and less than 24h ("23:00-03:00")
|
||||
(self.date_to.astimezone(tz).date() == self.date_from.astimezone(tz).date() + timedelta(days=1) and
|
||||
self.date_to.astimezone(tz).time() < self.date_from.astimezone(tz).time())
|
||||
# Do not show end time if this is a 5-day event because there's no way to make it understandable
|
||||
)
|
||||
if show_date_to:
|
||||
return '{} – {}'.format(
|
||||
_date(self.date_from.astimezone(tz), "TIME_FORMAT"),
|
||||
_date(self.date_to.astimezone(tz), "TIME_FORMAT"),
|
||||
)
|
||||
return _date(self.date_from.astimezone(tz), "TIME_FORMAT")
|
||||
|
||||
@property
|
||||
def timezone(self):
|
||||
return pytz_deprecation_shim.timezone(self.settings.timezone)
|
||||
|
||||
@@ -1199,6 +1199,8 @@ class Order(LockModel, LoggedModel):
|
||||
'invoices': [i.pk for i in invoices] if invoices else [],
|
||||
'attach_tickets': attach_tickets,
|
||||
'attach_ical': attach_ical,
|
||||
'attach_other_files': attach_other_files,
|
||||
'attach_cached_files': [cf.filename for cf in attach_cached_files] if attach_cached_files else [],
|
||||
}
|
||||
)
|
||||
|
||||
@@ -2857,6 +2859,8 @@ class OrderPosition(AbstractPosition):
|
||||
'invoices': [i.pk for i in invoices] if invoices else [],
|
||||
'attach_tickets': attach_tickets,
|
||||
'attach_ical': attach_ical,
|
||||
'attach_other_files': attach_other_files,
|
||||
'attach_cached_files': [],
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -286,6 +286,8 @@ class WaitingListEntry(LoggedModel):
|
||||
'subject': subject,
|
||||
'message': email_content,
|
||||
'recipient': recipient,
|
||||
'attach_other_files': attach_other_files,
|
||||
'attach_cached_files': [cf.filename for cf in attach_cached_files] if attach_cached_files else [],
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -330,18 +330,18 @@ class BasePaymentProvider:
|
||||
label=_('Enable payment method'),
|
||||
required=False,
|
||||
)),
|
||||
('_availability_date',
|
||||
RelativeDateField(
|
||||
label=_('Available until'),
|
||||
help_text=_('Users will not be able to choose this payment provider after the given date.'),
|
||||
required=False,
|
||||
)),
|
||||
('_availability_start',
|
||||
RelativeDateField(
|
||||
label=_('Available from'),
|
||||
help_text=_('Users will not be able to choose this payment provider before the given date.'),
|
||||
required=False,
|
||||
)),
|
||||
('_availability_date',
|
||||
RelativeDateField(
|
||||
label=_('Available until'),
|
||||
help_text=_('Users will not be able to choose this payment provider after the given date.'),
|
||||
required=False,
|
||||
)),
|
||||
('_total_min',
|
||||
forms.DecimalField(
|
||||
label=_('Minimum order total'),
|
||||
@@ -1308,6 +1308,9 @@ class OffsettingProvider(BasePaymentProvider):
|
||||
def payment_control_render(self, request: HttpRequest, payment: OrderPayment) -> str:
|
||||
return _('Balanced against orders: %s' % ', '.join(payment.info_data['orders']))
|
||||
|
||||
def refund_control_render(self, request: HttpRequest, payment: OrderPayment) -> str:
|
||||
return self.payment_control_render(request, payment)
|
||||
|
||||
|
||||
class GiftCardPayment(BasePaymentProvider):
|
||||
identifier = "giftcard"
|
||||
|
||||
@@ -2108,7 +2108,7 @@ DEFAULTS = {
|
||||
'form_class': I18nFormField,
|
||||
'form_kwargs': dict(
|
||||
label=_("Event description"),
|
||||
widget=I18nMarkdownTextarea,
|
||||
widget=I18nTextarea,
|
||||
help_text=_(
|
||||
"You can use this to share information with your attendees, such as travel information or the link to a digital event. "
|
||||
"If you keep it empty, we will put a link to the event shop, the admission time, and your organizer name in there. "
|
||||
@@ -2987,7 +2987,7 @@ Your {organizer} team""")) # noqa: W291
|
||||
help_text=_('This picture will be used as a preview if you post links to your ticket shop on social media. '
|
||||
'Facebook advises to use a picture size of 1200 x 630 pixels, however some platforms like '
|
||||
'WhatsApp and Reddit only show a square preview, so we recommend to make sure it still looks good '
|
||||
'only the center square is shown. If you do not fill this, we will use the logo given above.')
|
||||
'if only the center square is shown. If you do not fill this, we will use the logo given above.')
|
||||
),
|
||||
'serializer_class': UploadedFileField,
|
||||
'serializer_kwargs': dict(
|
||||
@@ -3291,6 +3291,8 @@ Your {organizer} team""")) # noqa: W291
|
||||
label=_('Validity of gift card codes in years'),
|
||||
help_text=_('If you set a number here, gift cards will by default expire at the end of the year after this '
|
||||
'many years. If you keep it empty, gift cards do not have an explicit expiry date.'),
|
||||
min_value=0,
|
||||
max_value=99,
|
||||
)
|
||||
},
|
||||
'cookie_consent': {
|
||||
@@ -3710,6 +3712,14 @@ COUNTRIES_WITH_STATE_IN_ADDRESS = {
|
||||
'MY': (['State', 'Federal territory'], 'long'),
|
||||
'MX': (['State', 'Federal district'], 'short'),
|
||||
'US': (['State', 'Outlying area', 'District'], 'short'),
|
||||
'IT': (['Province', 'Free municipal consortium', 'Metropolitan city', 'Autonomous province',
|
||||
'Free municipal consortium', 'Decentralized regional entity'], 'short'),
|
||||
}
|
||||
COUNTRY_STATE_LABEL = {
|
||||
# Countries in which the "State" field should not be called "State"
|
||||
'CA': pgettext_lazy('address', 'Province'),
|
||||
'JP': pgettext_lazy('address', 'Prefecture'),
|
||||
'IT': pgettext_lazy('address', 'Province'),
|
||||
}
|
||||
|
||||
settings_hierarkey = Hierarkey(attribute_name='settings')
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<code>Host: {{ request.headers.Host }}</code>
|
||||
{% if xfh %}
|
||||
<br>
|
||||
<code>X-Forwarded-For: {{ xfh }}</code>
|
||||
<code>X-Forwarded-Host: {{ xfh }}</code>
|
||||
{% if not settings.USE_X_FORWARDED_HOST %}({% trans "ignored" %}){% endif %}
|
||||
{% endif %}
|
||||
</dd>
|
||||
|
||||
@@ -15,10 +15,7 @@
|
||||
{{ event.name }}
|
||||
<br>
|
||||
{% if event.has_subevents and ev.name|upper != event.name|upper %}{{ ev.name }}<br>{% endif %}
|
||||
{{ ev.get_date_range_display }}
|
||||
{% if event.settings.show_times %}
|
||||
{{ ev.date_from|date:"TIME_FORMAT" }}
|
||||
{% endif %}
|
||||
{{ ev.get_date_range_display_with_times }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -107,10 +104,7 @@
|
||||
{% if groupkey.2.name|upper != event.name|upper %}
|
||||
{{ groupkey.2.name }} ·
|
||||
{% endif %}
|
||||
{{ groupkey.2.get_date_range_display }}
|
||||
{% if event.settings.show_times %}
|
||||
{{ groupkey.2.date_from|date:"TIME_FORMAT" }}
|
||||
{% endif %}
|
||||
{{ groupkey.2.get_date_range_display_with_times }}
|
||||
{% if groupkey.2.location %}
|
||||
<br>
|
||||
{{ groupkey.2.location|oneline }}
|
||||
|
||||
@@ -21,12 +21,15 @@
|
||||
#
|
||||
import pycountry
|
||||
from django.http import JsonResponse
|
||||
from django.utils.translation import pgettext
|
||||
|
||||
from pretix.base.addressvalidation import (
|
||||
COUNTRIES_WITH_STREET_ZIPCODE_AND_CITY_REQUIRED,
|
||||
)
|
||||
from pretix.base.models.tax import VAT_ID_COUNTRIES
|
||||
from pretix.base.settings import COUNTRIES_WITH_STATE_IN_ADDRESS
|
||||
from pretix.base.settings import (
|
||||
COUNTRIES_WITH_STATE_IN_ADDRESS, COUNTRY_STATE_LABEL,
|
||||
)
|
||||
|
||||
|
||||
def states(request):
|
||||
@@ -35,7 +38,11 @@ def states(request):
|
||||
'street': {'required': True},
|
||||
'zipcode': {'required': cc in COUNTRIES_WITH_STREET_ZIPCODE_AND_CITY_REQUIRED},
|
||||
'city': {'required': cc in COUNTRIES_WITH_STREET_ZIPCODE_AND_CITY_REQUIRED},
|
||||
'state': {'visible': cc in COUNTRIES_WITH_STATE_IN_ADDRESS, 'required': cc in COUNTRIES_WITH_STATE_IN_ADDRESS},
|
||||
'state': {
|
||||
'visible': cc in COUNTRIES_WITH_STATE_IN_ADDRESS,
|
||||
'required': cc in COUNTRIES_WITH_STATE_IN_ADDRESS,
|
||||
'label': COUNTRY_STATE_LABEL.get(cc, pgettext('address', 'State')),
|
||||
},
|
||||
'vat_id': {'visible': cc in VAT_ID_COUNTRIES, 'required': False},
|
||||
}
|
||||
if cc not in COUNTRIES_WITH_STATE_IN_ADDRESS:
|
||||
|
||||
Reference in New Issue
Block a user