From: Yoan Le Clanche Date: Tue, 27 Jan 2026 13:56:39 +0000 (+0100) Subject: update register form and add billing X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=a4afecc2fcbc1758580cd06fb5324ae42ef90d57;p=teleforma.git update register form and add billing --- diff --git a/teleforma/forms.py b/teleforma/forms.py index 57193a91..c411e778 100644 --- a/teleforma/forms.py +++ b/teleforma/forms.py @@ -215,6 +215,19 @@ else: city = CharField(label=_('City'), max_length=255) country = CharField(label=_('Country'), max_length=255) telephone = CharField(label=_('Telephone'), max_length=255) + lawyer_country = CharField(label='Pays dans lequel vous êtes avocat', max_length=255, required=True) + different_billing_address = forms.ChoiceField( + choices=[('False', 'Non'), ('True', 'Oui')], + label='Adresse de facturation différente ?', + widget=forms.RadioSelect(), + initial='False', + required=False + ) + billing_address = CharField(label='Adresse de facturation', max_length=255, required=False) + billing_address_detail = CharField(label='Complément adresse', max_length=255, required=False) + billing_postal_code = CharField(label='Code postal', max_length=255, required=False) + billing_city = CharField(label='Ville', max_length=255, required=False) + billing_country = CharField(label='Pays', max_length=255, required=False) # student platform_only = forms.ChoiceField(choices = TRUE_FALSE_CHOICES, label='E-learning uniquement', @@ -249,9 +262,24 @@ else: self.fields['first_name'].required = True self.fields['last_name'].required = True self.fields['email'].required = True - self.user_fields = ['first_name', 'last_name', 'email', 'address', 'address_detail', 'postal_code', 'city', 'country', 'telephone'] + self.user_fields = ['first_name', 'last_name', 'email', 'address', 'address_detail', 'postal_code', 'city', 'country', 'telephone', 'lawyer_country', 'different_billing_address', 'billing_address', 'billing_address_detail', 'billing_postal_code', 'billing_city', 'billing_country'] self.training_fields = ['platform_only', 'period', 'training', 'courses'] + def clean(self): + cleaned_data = super().clean() + different_billing = cleaned_data.get('different_billing_address') + if different_billing == 'True': + required_billing_fields = { + 'billing_address': 'Adresse de facturation', + 'billing_postal_code': 'Code postal de facturation', + 'billing_city': 'Ville de facturation', + 'billing_country': 'Pays de facturation', + } + for field_name, field_label in required_billing_fields.items(): + if not cleaned_data.get(field_name): + self.add_error(field_name, f'{field_label} est obligatoire.') + return cleaned_data + def save(self, commit=True): data = self.cleaned_data @@ -270,7 +298,13 @@ else: postal_code=data['postal_code'], city=data['city'], country=data['country'], - telephone=data['telephone'] + telephone=data['telephone'], + lawyer_country=data.get('lawyer_country'), + billing_address=data.get('billing_address'), + billing_address_detail=data.get('billing_address_detail'), + billing_postal_code=data.get('billing_postal_code'), + billing_city=data.get('billing_city'), + billing_country=data.get('billing_country') ) if commit: profile.save() diff --git a/teleforma/migrations/0014_add_lawyer_country_and_billing_address.py b/teleforma/migrations/0014_add_lawyer_country_and_billing_address.py new file mode 100644 index 00000000..7b394a5d --- /dev/null +++ b/teleforma/migrations/0014_add_lawyer_country_and_billing_address.py @@ -0,0 +1,43 @@ +# Generated by Django 3.2.25 on 2026-01-27 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('teleforma', '0013_auto_20240926_1615'), + ] + + operations = [ + migrations.AddField( + model_name='profile', + name='lawyer_country', + field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Pays dans lequel vous êtes avocat'), + ), + migrations.AddField( + model_name='profile', + name='billing_address', + field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Adresse de facturation'), + ), + migrations.AddField( + model_name='profile', + name='billing_address_detail', + field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Complément adresse de facturation'), + ), + migrations.AddField( + model_name='profile', + name='billing_postal_code', + field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Code postal de facturation'), + ), + migrations.AddField( + model_name='profile', + name='billing_city', + field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Ville de facturation'), + ), + migrations.AddField( + model_name='profile', + name='billing_country', + field=models.CharField(blank=True, max_length=255, null=True, verbose_name='Pays de facturation'), + ), + ] diff --git a/teleforma/models/crfpa.py b/teleforma/models/crfpa.py index 4d2dcef6..a0a69f03 100755 --- a/teleforma/models/crfpa.py +++ b/teleforma/models/crfpa.py @@ -227,6 +227,18 @@ class Profile(models.Model): max_length=15, blank=True, null=True) siret = models.CharField('Siret', max_length=13, blank=True, null=True) + lawyer_country = models.CharField( + 'Pays dans lequel vous êtes avocat', max_length=255, blank=True, null=True) + billing_address = models.CharField( + 'Adresse de facturation', max_length=255, blank=True, null=True) + billing_address_detail = models.CharField( + 'Complément adresse de facturation', max_length=255, blank=True, null=True) + billing_postal_code = models.CharField( + 'Code postal de facturation', max_length=255, blank=True, null=True) + billing_city = models.CharField( + 'Ville de facturation', max_length=255, blank=True, null=True) + billing_country = models.CharField( + 'Pays de facturation', max_length=255, blank=True, null=True) class Meta(MetaCore): db_table = app_label + '_' + 'profiles' diff --git a/teleforma/templates/registration/registration_form.html b/teleforma/templates/registration/registration_form.html index e898d848..c1eaeedf 100644 --- a/teleforma/templates/registration/registration_form.html +++ b/teleforma/templates/registration/registration_form.html @@ -159,17 +159,58 @@ $("[name='fascicule']").parent().hide(); } + function updateBillingAddress() { + var differentBilling = $("[name='different_billing_address']:checked").val() === 'True'; + var requiredBillingFields = ['billing_address', 'billing_postal_code', 'billing_city', 'billing_country']; + var optionalBillingFields = ['billing_address_detail']; + var allBillingFields = requiredBillingFields.concat(optionalBillingFields); + + allBillingFields.forEach(function(fieldName) { + var fieldContainer = $("[name='" + fieldName + "']").closest('.info_champs'); + var label = fieldContainer.find('label'); + if(differentBilling) { + fieldContainer.show(); + // Ajouter l'astérisque pour les champs obligatoires + if(requiredBillingFields.indexOf(fieldName) !== -1) { + if(label.find('.required').length === 0) { + label.append('*'); + } + } + } else { + fieldContainer.hide(); + // Retirer l'astérisque + label.find('.required').remove(); + } + }); + } + $(document).ready(function () { trainingId = $("#id_training").val(); updateTrainings(); $("#id_period, #id_platform_only").change(updateTrainings); updateFascicule(); $("[name='platform_only']").change(updateFascicule); + updateBillingAddress(); + $("[name='different_billing_address']").change(updateBillingAddress); }); {% endblock %} diff --git a/teleforma/templates/registration/registration_pdf.html b/teleforma/templates/registration/registration_pdf.html index 470c2837..1b0b4507 100644 --- a/teleforma/templates/registration/registration_pdf.html +++ b/teleforma/templates/registration/registration_pdf.html @@ -46,8 +46,18 @@ {% trans "Address" %} : - {{ profile.address }} {{ profile.postal_code }} {{ profile.city }}, {{ profile.country }} + {{ profile.address }}{% if profile.address_detail %}, {{ profile.address_detail }}{% endif %} {{ profile.postal_code }} {{ profile.city }}, {{ profile.country }} + + Pays dans lequel vous êtes avocat : + {{ profile.lawyer_country }} + + {% if profile.billing_address %} + + Adresse de facturation : + {{ profile.billing_address }}{% if profile.billing_address_detail %}, {{ profile.billing_address_detail }}{% endif %} {{ profile.billing_postal_code }} {{ profile.billing_city }}, {{ profile.billing_country }} + + {% endif %} {% trans "Telephone" %} : {{ profile.telephone }}