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',
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
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()
--- /dev/null
+# 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'),
+ ),
+ ]
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'
$("[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('<span class="required">*</span>');
+ }
+ }
+ } 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);
});
</script>
<style>
select {
width: 222px;
}
+ #id_different_billing_address {
+ display: flex;
+ gap: 20px;
+ }
+ #id_different_billing_address li {
+ list-style: none;
+ display: flex;
+ align-items: center;
+ gap: 5px;
+ }
+ #id_different_billing_address label {
+ margin: 0;
+ font-weight: normal;
+ }
</style>
{% endblock %}
</tr>
<tr>
<td class="bold">{% trans "Address" %} : </td>
- <td>{{ profile.address }} {{ profile.postal_code }} {{ profile.city }}, {{ profile.country }}</td>
+ <td>{{ profile.address }}{% if profile.address_detail %}, {{ profile.address_detail }}{% endif %} {{ profile.postal_code }} {{ profile.city }}, {{ profile.country }}</td>
</tr>
+ <tr>
+ <td class="bold">Pays dans lequel vous êtes avocat : </td>
+ <td>{{ profile.lawyer_country }}</td>
+ </tr>
+ {% if profile.billing_address %}
+ <tr>
+ <td class="bold">Adresse de facturation : </td>
+ <td>{{ profile.billing_address }}{% if profile.billing_address_detail %}, {{ profile.billing_address_detail }}{% endif %} {{ profile.billing_postal_code }} {{ profile.billing_city }}, {{ profile.billing_country }}</td>
+ </tr>
+ {% endif %}
<tr>
<td class="bold">{% trans "Telephone" %} : </td>
<td>{{ profile.telephone }}</td>