From 4ce885ac6b4b761154efd558f5b92a981af6bde4 Mon Sep 17 00:00:00 2001 From: Sli Date: Fri, 11 Apr 2025 15:30:05 +0200 Subject: [PATCH] Default France value and cleaner handling of BillingInfo creation --- counter/forms.py | 1 - eboutic/models.py | 4 ++- .../eboutic/eboutic_billing_info.jinja | 2 +- eboutic/templates/eboutic/eboutic_main.jinja | 1 - .../eboutic/eboutic_makecommand.jinja | 3 ++- eboutic/views.py | 27 ++++++++++++++----- 6 files changed, 27 insertions(+), 11 deletions(-) diff --git a/counter/forms.py b/counter/forms.py index 10109b4d..27dc74d7 100644 --- a/counter/forms.py +++ b/counter/forms.py @@ -43,7 +43,6 @@ class BillingInfoForm(forms.ModelForm): ] widgets = { "phone_number": RegionalPhoneNumberWidget, - "country": AutoCompleteSelect, } diff --git a/eboutic/models.py b/eboutic/models.py index 60dddb91..b6daaf34 100644 --- a/eboutic/models.py +++ b/eboutic/models.py @@ -51,7 +51,9 @@ class BillingInfoState(Enum): MISSING_PHONE_NUMBER = 3 @classmethod - def from_model(cls, info: BillingInfo) -> BillingInfoState: + def from_model(cls, info: BillingInfo | None) -> BillingInfoState: + if info is None: + return cls.EMPTY for attr in [ "first_name", "last_name", diff --git a/eboutic/templates/eboutic/eboutic_billing_info.jinja b/eboutic/templates/eboutic/eboutic_billing_info.jinja index b498e234..4a1d0739 100644 --- a/eboutic/templates/eboutic/eboutic_billing_info.jinja +++ b/eboutic/templates/eboutic/eboutic_billing_info.jinja @@ -16,7 +16,7 @@ class="collapse-body" hx-trigger="submit" hx-post="{{ action }}" - hx-swap="outerHTML settle:100" + hx-swap="outerHTML" hx-target="closest span" x-show="collapsed" > diff --git a/eboutic/templates/eboutic/eboutic_main.jinja b/eboutic/templates/eboutic/eboutic_main.jinja index ee563dd0..1e070b95 100644 --- a/eboutic/templates/eboutic/eboutic_main.jinja +++ b/eboutic/templates/eboutic/eboutic_main.jinja @@ -66,7 +66,6 @@ {% trans %}Clear{% endtrans %}
- {% csrf_token %}