Address form: Add provinces for Italy

This commit is contained in:
Raphael Michel
2025-03-17 10:36:29 +01:00
committed by GitHub
parent 9581457d2f
commit 0cca053d45
11 changed files with 44 additions and 15 deletions

View File

@@ -43,7 +43,7 @@ from django.utils.translation import get_language
from django_scopes import scope
from pretix.base.models.auth import StaffSession
from pretix.base.settings import GlobalSettingsObject
from pretix.base.settings import COUNTRY_STATE_LABEL, GlobalSettingsObject
from pretix.control.navigation import (
get_event_navigation, get_global_navigation, get_organizer_navigation,
)
@@ -140,6 +140,7 @@ def _default_context(request):
ctx['js_time_format'] = get_javascript_format('TIME_INPUT_FORMATS')
ctx['js_locale'] = get_moment_locale()
ctx['select2locale'] = get_language()[:2]
ctx['COUNTRY_STATE_LABEL'] = COUNTRY_STATE_LABEL
ctx['warning_update_available'] = False
ctx['warning_update_check_active'] = False

View File

@@ -1475,7 +1475,9 @@ class CountriesAndEUAndStates(CountriesAndEU):
def __iter__(self):
for country_code, country_name in super().__iter__():
yield country_code, country_name
if country_code in COUNTRIES_WITH_STATE_IN_ADDRESS:
if country_code in COUNTRIES_WITH_STATE_IN_ADDRESS and country_code not in {"IT"}:
# Special case for Italy: Provinces are used in addresses, but are too low-level to
# have influence on taxes, so we avoid the bloat in the list of selectable countries.
types, form = COUNTRIES_WITH_STATE_IN_ADDRESS[country_code]
yield from sorted(((state.code, country_name + " - " + state.name)
for state in pycountry.subdivisions.get(country_code=country_code)

View File

@@ -9,6 +9,7 @@
{% load eventsignal %}
{% load l10n %}
{% load phone_format %}
{% load getitem %}
{% block title %}
{% blocktrans trimmed with code=order.code %}
Order details: {{ code }}
@@ -560,8 +561,8 @@
{% if line.street or line.zipcode or line.city or line.country %}
{{ line.street|default_if_none:""|linebreaksbr }}<br>
{{ line.zipcode|default_if_none:"" }} {{ line.city|default_if_none:"" }}<br>
{% if line.state %}{{ line.state_for_address }}<br>{% endif %}
{{ line.country.name|default_if_none:"" }}
{% if line.state %}<br>{{ line.state }}{% endif %}
{% else %}
<em>{% trans "not answered" %}</em>
{% endif %}
@@ -959,7 +960,7 @@
<dt>{% trans "Country" %}</dt>
<dd>{{ order.invoice_address.country.name|default:order.invoice_address.country_old }}</dd>
{% if order.invoice_address.state %}
<dt>{% trans "State" context "address" %}</dt>
<dt>{% trans "State" context "address" as state_label %}{{ COUNTRY_STATE_LABEL|getitem:order.invoice_address.country.code|default:state_label }}</dt>
<dd>{{ order.invoice_address.state_name }}</dd>
{% endif %}
{% if request.event.settings.invoice_address_vatid %}