From e8cbfb90427569dbdf7337e6336dcc3fb36f61d8 Mon Sep 17 00:00:00 2001 From: Nicolas Oudard Date: Wed, 4 Sep 2024 13:58:41 +0200 Subject: [PATCH] permettre les champs vide dans l'admin du model Programme (#1562) --- programmes/fixtures/programmes_for_tests.json | 108 ------------- .../0102_alter_logement_blank_and_null.py | 98 ++++++++++++ .../0103_alter_lot_blank_and_null.py | 62 ++++++++ ...104_alter_ref_cadastrale_blank_and_null.py | 39 +++++ ...105_alter_ref_programme1_blank_and_null.py | 45 ++++++ ...106_alter_ref_programme2_blank_and_null.py | 62 ++++++++ ...107_alter_ref_programme3_blank_and_null.py | 57 +++++++ ...108_alter_ref_programme4_blank_and_null.py | 62 ++++++++ ...109_alter_ref_programme5_blank_and_null.py | 36 +++++ ...110_alter_ref_programme6_blank_and_null.py | 144 ++++++++++++++++++ ...ogramme.py => 0111_historicalprogramme.py} | 97 ++++++------ programmes/models/models.py | 134 +++++++++------- programmes/signals.py | 15 +- programmes/tests/test_models.py | 10 +- 14 files changed, 749 insertions(+), 220 deletions(-) create mode 100644 programmes/migrations/0102_alter_logement_blank_and_null.py create mode 100644 programmes/migrations/0103_alter_lot_blank_and_null.py create mode 100644 programmes/migrations/0104_alter_ref_cadastrale_blank_and_null.py create mode 100644 programmes/migrations/0105_alter_ref_programme1_blank_and_null.py create mode 100644 programmes/migrations/0106_alter_ref_programme2_blank_and_null.py create mode 100644 programmes/migrations/0107_alter_ref_programme3_blank_and_null.py create mode 100644 programmes/migrations/0108_alter_ref_programme4_blank_and_null.py create mode 100644 programmes/migrations/0109_alter_ref_programme5_blank_and_null.py create mode 100644 programmes/migrations/0110_alter_ref_programme6_blank_and_null.py rename programmes/migrations/{0102_historicalprogramme.py => 0111_historicalprogramme.py} (71%) diff --git a/programmes/fixtures/programmes_for_tests.json b/programmes/fixtures/programmes_for_tests.json index a469dc86a..19d8c61b9 100644 --- a/programmes/fixtures/programmes_for_tests.json +++ b/programmes/fixtures/programmes_for_tests.json @@ -3,7 +3,6 @@ "model": "programmes.programme", "pk": 1, "fields": { - "parent": null, "uuid": "c3449e15-3739-4a35-8587-09be8c5ee007", "nom": "Programme 1", "numero_operation": "12345", @@ -12,9 +11,7 @@ "adresse": "22 rue segur", "code_postal": "75007", "ville": "Paris", - "code_insee_commune": null, "code_insee_departement": "75", - "code_insee_region": null, "annee_gestion_programmation": 2018, "zone_123": "3", "zone_abc": "B1", @@ -25,28 +22,14 @@ "nb_locaux_commerciaux": 5, "nb_bureaux": 25, "autres_locaux_hors_convention": "quelques uns", - "vendeur": "", - "acquereur": null, - "date_acte_notarie": null, - "reference_notaire": "", "reference_publication_acte": "{\"text\": \"this is a test\", \"files\": {\"8c9b6894-1de4-4b45-bd50-e9416dd3ee6b\": {\"uuid\": \"8c9b6894-1de4-4b45-bd50-e9416dd3ee6b\", \"thumbnail\": \"data:image/png;base64,BLAHBLAH==\", \"size\": \"31185\", \"filename\": \"acquereur1.png\", \"content_type\": \"image/png\"}, \"0c48af64-c852-4e6f-ae86-265615913ac9\": {\"uuid\": \"0c48af64-c852-4e6f-ae86-265615913ac9\", \"thumbnail\": \"data:image/png;base64,BLIHBLIH==\", \"size\": \"69076\", \"filename\": \"acquereur2.png\", \"content_type\": \"image/png\"}}}", - "acte_de_propriete": "", "effet_relatif": "n'importe quoi", "certificat_adressage": "n'importe quoi", "reference_cadastrale": "{\"text\": \"this is a test\", \"files\": {\"98ae5093-ff07-4008-bb61-6fa5e7e34fd2\": {\"uuid\": \"98ae5093-ff07-4008-bb61-6fa5e7e34fd2\", \"thumbnail\": \"data:image/png;base64,BLAHBLAH==\", \"size\": \"31185\", \"filename\": \"acquereur1.png\", \"content_type\": \"image/png\"}, \"daf5cc14-e5fd-4125-affa-3d7003b1dcc8\": {\"uuid\": \"daf5cc14-e5fd-4125-affa-3d7003b1dcc8\", \"thumbnail\": \"data:image/png;base64,BLIHBLIH==\", \"size\": \"69076\", \"filename\": \"acquereur2.png\", \"content_type\": \"image/png\"}}}", - "edd_volumetrique": null, - "mention_publication_edd_volumetrique": null, - "edd_classique": null, - "mention_publication_edd_classique": null, "permis_construire": "123 456 789 ABC", "date_achevement_previsible": "2024-01-02", "date_achat": "2022-01-02", "date_achevement": "2024-04-11", - "date_autorisation_hors_habitat_inclusif": null, - "date_convention_location": null, - "date_residence_argement_gestionnaire_intermediation": null, - "departement_residence_argement_gestionnaire_intermediation": null, - "ville_signature_residence_agrement_gestionnaire_intermediation": null, "date_achevement_compile": "2024-04-11", "cree_le": "2023-03-08T20:43:46.064Z", "mis_a_jour_le": "2023-03-08T20:43:46.064Z" @@ -56,7 +39,6 @@ "model": "programmes.programme", "pk": 2, "fields": { - "parent": null, "uuid": "0bc134b9-4f50-4c2a-a858-e4696c121ff0", "nom": "Programme 1", "numero_operation": "98765", @@ -65,9 +47,7 @@ "adresse": "22 rue segur", "code_postal": "13001", "ville": "Paris", - "code_insee_commune": null, "code_insee_departement": "13", - "code_insee_region": null, "annee_gestion_programmation": 2018, "zone_123": "3", "zone_abc": "B1", @@ -80,26 +60,14 @@ "autres_locaux_hors_convention": "quelques uns", "vendeur": "{\"text\": \"this is a test\", \"files\": {\"cff0c56e-40bd-409b-8116-d50430db2239\": {\"uuid\": \"cff0c56e-40bd-409b-8116-d50430db2239\", \"thumbnail\": \"data:image/png;base64,BLAHBLAH==\", \"size\": \"31185\", \"filename\": \"acquereur1.png\", \"content_type\": \"image/png\"}, \"a94a4c00-1ee1-4fbd-b200-a758379ec37f\": {\"uuid\": \"a94a4c00-1ee1-4fbd-b200-a758379ec37f\", \"thumbnail\": \"data:image/png;base64,BLIHBLIH==\", \"size\": \"69076\", \"filename\": \"acquereur2.png\", \"content_type\": \"image/png\"}}}", "acquereur": "n'importe quoi", - "date_acte_notarie": null, "reference_notaire": "{\"text\": \"this is a test\", \"files\": {\"45079d28-f737-44b7-9f6a-c1e8367072a5\": {\"uuid\": \"45079d28-f737-44b7-9f6a-c1e8367072a5\", \"thumbnail\": \"data:image/png;base64,BLAHBLAH==\", \"size\": \"31185\", \"filename\": \"acquereur1.png\", \"content_type\": \"image/png\"}, \"df747b0d-62c7-4fb3-9fda-37f3b682df80\": {\"uuid\": \"df747b0d-62c7-4fb3-9fda-37f3b682df80\", \"thumbnail\": \"data:image/png;base64,BLIHBLIH==\", \"size\": \"69076\", \"filename\": \"acquereur2.png\", \"content_type\": \"image/png\"}}}", "reference_publication_acte": "{\"text\": \"this is a test\", \"files\": {\"80ecbde5-da41-4ece-a35b-19665b8b2b12\": {\"uuid\": \"80ecbde5-da41-4ece-a35b-19665b8b2b12\", \"thumbnail\": \"data:image/png;base64,BLAHBLAH==\", \"size\": \"31185\", \"filename\": \"acquereur1.png\", \"content_type\": \"image/png\"}, \"ae57c1f9-62cb-46df-b496-2f4c78429a4c\": {\"uuid\": \"ae57c1f9-62cb-46df-b496-2f4c78429a4c\", \"thumbnail\": \"data:image/png;base64,BLIHBLIH==\", \"size\": \"69076\", \"filename\": \"acquereur2.png\", \"content_type\": \"image/png\"}}}", "acte_de_propriete": "{\"text\": \"this is a test\", \"files\": {\"8f25d1cd-cb65-4596-9f74-758c6eb00283\": {\"uuid\": \"8f25d1cd-cb65-4596-9f74-758c6eb00283\", \"thumbnail\": \"data:image/png;base64,BLAHBLAH==\", \"size\": \"31185\", \"filename\": \"acquereur1.png\", \"content_type\": \"image/png\"}, \"4a5ca2ab-f739-4b9d-ba71-4412268e78f4\": {\"uuid\": \"4a5ca2ab-f739-4b9d-ba71-4412268e78f4\", \"thumbnail\": \"data:image/png;base64,BLIHBLIH==\", \"size\": \"69076\", \"filename\": \"acquereur2.png\", \"content_type\": \"image/png\"}}}", - "effet_relatif": null, "certificat_adressage": "{\"text\": \"this is a test\", \"files\": {\"4feccfda-205e-42de-b215-46e94b32ddd1\": {\"uuid\": \"4feccfda-205e-42de-b215-46e94b32ddd1\", \"thumbnail\": \"data:image/png;base64,BLAHBLAH==\", \"size\": \"31185\", \"filename\": \"acquereur1.png\", \"content_type\": \"image/png\"}, \"6441b179-5ec6-4ca5-bb64-f915f83c34ab\": {\"uuid\": \"6441b179-5ec6-4ca5-bb64-f915f83c34ab\", \"thumbnail\": \"data:image/png;base64,BLIHBLIH==\", \"size\": \"69076\", \"filename\": \"acquereur2.png\", \"content_type\": \"image/png\"}}}", - "reference_cadastrale": "", - "edd_volumetrique": null, - "mention_publication_edd_volumetrique": null, - "edd_classique": null, - "mention_publication_edd_classique": null, "permis_construire": "123 456 789 ABC", "date_achevement_previsible": "2024-01-02", "date_achat": "2022-01-02", "date_achevement": "2024-04-11", - "date_autorisation_hors_habitat_inclusif": null, - "date_convention_location": null, - "date_residence_argement_gestionnaire_intermediation": null, - "departement_residence_argement_gestionnaire_intermediation": null, - "ville_signature_residence_agrement_gestionnaire_intermediation": null, "date_achevement_compile": "2024-04-11", "cree_le": "2023-03-08T20:43:46.137Z", "mis_a_jour_le": "2023-03-08T20:43:46.137Z" @@ -109,32 +77,13 @@ "model": "programmes.lot", "pk": 1, "fields": { - "parent": null, "uuid": "09b07c04-a46a-4d41-a463-71b00c2d38ac", - "nb_logements": null, "programme": 1, "financement": "PLAI", "type_habitat": "INDIVIDUEL", - "edd_volumetrique": "", "edd_classique": "{\"text\": \"this is a test\", \"files\": {\"fbb9890f-171b-402d-a35e-71e1bd791b70\": {\"uuid\": \"fbb9890f-171b-402d-a35e-71e1bd791b70\", \"thumbnail\": \"data:image/png;base64,BLAHBLAH==\", \"size\": \"31185\", \"filename\": \"acquereur1.png\", \"content_type\": \"image/png\"}, \"dccd310d-2e50-45d8-a477-db7b08ae1d71\": {\"uuid\": \"dccd310d-2e50-45d8-a477-db7b08ae1d71\", \"thumbnail\": \"data:image/png;base64,BLIHBLIH==\", \"size\": \"69076\", \"filename\": \"acquereur2.png\", \"content_type\": \"image/png\"}}}", - "annexe_caves": false, - "annexe_soussols": false, - "annexe_remises": false, - "annexe_ateliers": false, - "annexe_sechoirs": false, - "annexe_celliers": false, - "annexe_resserres": false, - "annexe_combles": false, - "annexe_balcons": false, - "annexe_loggias": false, - "annexe_terrasses": false, "lgts_mixite_sociale_negocies": 0, - "loyer_derogatoire": null, - "surface_habitable_totale": null, "surface_locaux_collectifs_residentiels": 0, - "foyer_residence_nb_garage_parking": null, - "foyer_residence_dependance": null, - "foyer_residence_locaux_hors_convention": null, "cree_le": "2023-03-08T20:43:46.080Z", "mis_a_jour_le": "2023-03-08T20:43:46.080Z" } @@ -143,32 +92,13 @@ "model": "programmes.lot", "pk": 2, "fields": { - "parent": null, "uuid": "3918d6f7-fcee-42c2-aa81-c56b97e802fb", - "nb_logements": null, "programme": 1, "financement": "PLUS", "type_habitat": "INDIVIDUEL", - "edd_volumetrique": "", "edd_classique": "n'importe quoi", - "annexe_caves": false, - "annexe_soussols": false, - "annexe_remises": false, - "annexe_ateliers": false, - "annexe_sechoirs": false, - "annexe_celliers": false, - "annexe_resserres": false, - "annexe_combles": false, - "annexe_balcons": false, - "annexe_loggias": false, - "annexe_terrasses": false, "lgts_mixite_sociale_negocies": 0, - "loyer_derogatoire": null, - "surface_habitable_totale": null, "surface_locaux_collectifs_residentiels": 0, - "foyer_residence_nb_garage_parking": null, - "foyer_residence_dependance": null, - "foyer_residence_locaux_hors_convention": null, "cree_le": "2023-03-08T20:43:46.095Z", "mis_a_jour_le": "2023-03-08T20:43:46.095Z" } @@ -177,32 +107,12 @@ "model": "programmes.lot", "pk": 3, "fields": { - "parent": null, "uuid": "3cabcbcd-9cf0-4cb8-8170-27be8e9e159c", - "nb_logements": null, "programme": 2, "financement": "PLAI", "type_habitat": "INDIVIDUEL", - "edd_volumetrique": "", - "edd_classique": null, - "annexe_caves": false, - "annexe_soussols": false, - "annexe_remises": false, - "annexe_ateliers": false, - "annexe_sechoirs": false, - "annexe_celliers": false, - "annexe_resserres": false, - "annexe_combles": false, - "annexe_balcons": false, - "annexe_loggias": false, - "annexe_terrasses": false, "lgts_mixite_sociale_negocies": 0, - "loyer_derogatoire": null, - "surface_habitable_totale": null, "surface_locaux_collectifs_residentiels": 0, - "foyer_residence_nb_garage_parking": null, - "foyer_residence_dependance": null, - "foyer_residence_locaux_hors_convention": null, "cree_le": "2023-03-08T20:43:46.144Z", "mis_a_jour_le": "2023-03-08T20:43:46.144Z" } @@ -211,32 +121,14 @@ "model": "programmes.lot", "pk": 4, "fields": { - "parent": null, "uuid": "3be91b08-5bb7-4c03-95a8-168e6602ac91", - "nb_logements": null, "programme": 2, "financement": "PLUS", "type_habitat": "COLLECTIF", "edd_volumetrique": "n'importe quoi", "edd_classique": "n'importe quoi", - "annexe_caves": false, - "annexe_soussols": false, - "annexe_remises": false, - "annexe_ateliers": false, - "annexe_sechoirs": false, - "annexe_celliers": false, - "annexe_resserres": false, - "annexe_combles": false, - "annexe_balcons": false, - "annexe_loggias": false, - "annexe_terrasses": false, "lgts_mixite_sociale_negocies": 0, - "loyer_derogatoire": null, - "surface_habitable_totale": null, "surface_locaux_collectifs_residentiels": 0, - "foyer_residence_nb_garage_parking": null, - "foyer_residence_dependance": null, - "foyer_residence_locaux_hors_convention": null, "cree_le": "2023-03-08T20:43:46.150Z", "mis_a_jour_le": "2023-03-08T20:43:46.150Z" } diff --git a/programmes/migrations/0102_alter_logement_blank_and_null.py b/programmes/migrations/0102_alter_logement_blank_and_null.py new file mode 100644 index 000000000..d26f3c5c9 --- /dev/null +++ b/programmes/migrations/0102_alter_logement_blank_and_null.py @@ -0,0 +1,98 @@ +# Generated by Django 4.2.13 on 2024-09-03 20:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + atomic = False + + dependencies = [ + ("instructeurs", "0001_initial_squashed_0017_auto_20230925_1209"), + ("programmes", "0101_programme_reassign_command_old_admin_backup"), + ] + + operations = [ + migrations.AlterField( + model_name="logement", + name="coeficient", + field=models.DecimalField( + blank=True, + decimal_places=4, + max_digits=12, + null=True, + verbose_name="Coefficient propre au logement", + ), + ), + migrations.AlterField( + model_name="logement", + name="loyer", + field=models.DecimalField( + blank=True, decimal_places=2, max_digits=12, null=True + ), + ), + migrations.AlterField( + model_name="logement", + name="loyer_par_metre_carre", + field=models.DecimalField( + blank=True, + decimal_places=2, + max_digits=12, + null=True, + verbose_name="Loyer maximum en € par m² de surface utile", + ), + ), + migrations.AlterField( + model_name="logement", + name="surface_annexes", + field=models.DecimalField( + blank=True, decimal_places=2, max_digits=12, null=True + ), + ), + migrations.AlterField( + model_name="logement", + name="surface_annexes_retenue", + field=models.DecimalField( + blank=True, decimal_places=2, max_digits=12, null=True + ), + ), + migrations.AlterField( + model_name="logement", + name="surface_corrigee", + field=models.DecimalField( + blank=True, + decimal_places=2, + max_digits=12, + null=True, + verbose_name="Surface corrigée", + ), + ), + migrations.AlterField( + model_name="logement", + name="surface_habitable", + field=models.DecimalField( + blank=True, + decimal_places=2, + max_digits=12, + null=True, + verbose_name="Surface habitable", + ), + ), + migrations.AlterField( + model_name="logement", + name="surface_utile", + field=models.DecimalField( + blank=True, + decimal_places=2, + max_digits=12, + null=True, + verbose_name="Surface utile", + ), + ), + migrations.AlterField( + model_name="logementedd", + name="numero_lot", + field=models.CharField(blank=True, default="", max_length=255), + preserve_default=False, + ), + ] diff --git a/programmes/migrations/0103_alter_lot_blank_and_null.py b/programmes/migrations/0103_alter_lot_blank_and_null.py new file mode 100644 index 000000000..21b367196 --- /dev/null +++ b/programmes/migrations/0103_alter_lot_blank_and_null.py @@ -0,0 +1,62 @@ +# Generated by Django 4.2.13 on 2024-09-03 20:37 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + atomic = False + + dependencies = [ + ("instructeurs", "0001_initial_squashed_0017_auto_20230925_1209"), + ("programmes", "0102_alter_logement_blank_and_null"), + ] + + operations = [ + migrations.AlterField( + model_name="lot", + name="edd_classique", + field=models.TextField(blank=True, default="", max_length=50000), + preserve_default=False, + ), + migrations.AlterField( + model_name="lot", + name="edd_volumetrique", + field=models.TextField(blank=True, default="", max_length=50000), + preserve_default=False, + ), + migrations.AlterField( + model_name="lot", + name="loyer_derogatoire", + field=models.DecimalField( + blank=True, + decimal_places=2, + max_digits=6, + null=True, + verbose_name="Loyer dérogatoire", + ), + ), + migrations.AlterField( + model_name="lot", + name="nb_logements", + field=models.IntegerField(blank=True, null=True), + ), + migrations.AlterField( + model_name="lot", + name="parent", + field=models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + to="programmes.lot", + ), + ), + migrations.AlterField( + model_name="lot", + name="surface_habitable_totale", + field=models.DecimalField( + blank=True, decimal_places=2, max_digits=12, null=True + ), + ), + ] diff --git a/programmes/migrations/0104_alter_ref_cadastrale_blank_and_null.py b/programmes/migrations/0104_alter_ref_cadastrale_blank_and_null.py new file mode 100644 index 000000000..fccd2c7d3 --- /dev/null +++ b/programmes/migrations/0104_alter_ref_cadastrale_blank_and_null.py @@ -0,0 +1,39 @@ +# Generated by Django 4.2.13 on 2024-09-03 20:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + atomic = False + + dependencies = [ + ("instructeurs", "0001_initial_squashed_0017_auto_20230925_1209"), + ("programmes", "0103_alter_lot_blank_and_null"), + ] + + operations = [ + migrations.AlterField( + model_name="referencecadastrale", + name="lieudit", + field=models.CharField(blank=True, default="", max_length=255), + preserve_default=False, + ), + migrations.AlterField( + model_name="referencecadastrale", + name="numero", + field=models.IntegerField(blank=True, null=True), + ), + migrations.AlterField( + model_name="referencecadastrale", + name="section", + field=models.CharField(blank=True, default="", max_length=255), + preserve_default=False, + ), + migrations.AlterField( + model_name="referencecadastrale", + name="surface", + field=models.CharField(blank=True, default="", max_length=255), + preserve_default=False, + ), + ] diff --git a/programmes/migrations/0105_alter_ref_programme1_blank_and_null.py b/programmes/migrations/0105_alter_ref_programme1_blank_and_null.py new file mode 100644 index 000000000..2fefa30f6 --- /dev/null +++ b/programmes/migrations/0105_alter_ref_programme1_blank_and_null.py @@ -0,0 +1,45 @@ +# Generated by Django 4.2.13 on 2024-09-03 20:37 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + atomic = False + + dependencies = [ + ("instructeurs", "0001_initial_squashed_0017_auto_20230925_1209"), + ("programmes", "0104_alter_ref_cadastrale_blank_and_null"), + ] + + operations = [ + migrations.AlterField( + model_name="programme", + name="acquereur", + field=models.TextField(blank=True, default=""), + preserve_default=False, + ), + migrations.AlterField( + model_name="programme", + name="acte_de_propriete", + field=models.TextField(blank=True, default=""), + preserve_default=False, + ), + migrations.AlterField( + model_name="programme", + name="administration", + field=models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.SET_NULL, + to="instructeurs.administration", + ), + ), + migrations.AlterField( + model_name="programme", + name="adresse", + field=models.TextField(blank=True, default=""), + preserve_default=False, + ), + ] diff --git a/programmes/migrations/0106_alter_ref_programme2_blank_and_null.py b/programmes/migrations/0106_alter_ref_programme2_blank_and_null.py new file mode 100644 index 000000000..a2ef7bb55 --- /dev/null +++ b/programmes/migrations/0106_alter_ref_programme2_blank_and_null.py @@ -0,0 +1,62 @@ +# Generated by Django 4.2.13 on 2024-09-03 20:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + atomic = False + + dependencies = [ + ("instructeurs", "0001_initial_squashed_0017_auto_20230925_1209"), + ("programmes", "0105_alter_ref_programme1_blank_and_null"), + ] + + operations = [ + migrations.AlterField( + model_name="programme", + name="annee_gestion_programmation", + field=models.IntegerField(blank=True, null=True), + ), + migrations.AlterField( + model_name="programme", + name="autres_locaux_hors_convention", + field=models.TextField(blank=True, default=""), + preserve_default=False, + ), + migrations.AlterField( + model_name="programme", + name="certificat_adressage", + field=models.TextField(blank=True, default=""), + preserve_default=False, + ), + migrations.AlterField( + model_name="programme", + name="code_insee_commune", + field=models.CharField(blank=True, default="", max_length=10), + preserve_default=False, + ), + migrations.AlterField( + model_name="programme", + name="code_insee_departement", + field=models.CharField(blank=True, default="", max_length=10), + preserve_default=False, + ), + migrations.AlterField( + model_name="programme", + name="code_insee_region", + field=models.CharField(blank=True, default="", max_length=10), + preserve_default=False, + ), + migrations.AlterField( + model_name="programme", + name="code_postal", + field=models.CharField(blank=True, default="", max_length=5), + preserve_default=False, + ), + migrations.AlterField( + model_name="programme", + name="date_achat", + field=models.DateField(blank=True, null=True), + ), + ] diff --git a/programmes/migrations/0107_alter_ref_programme3_blank_and_null.py b/programmes/migrations/0107_alter_ref_programme3_blank_and_null.py new file mode 100644 index 000000000..321c61f93 --- /dev/null +++ b/programmes/migrations/0107_alter_ref_programme3_blank_and_null.py @@ -0,0 +1,57 @@ +# Generated by Django 4.2.13 on 2024-09-03 20:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + atomic = False + + dependencies = [ + ("instructeurs", "0001_initial_squashed_0017_auto_20230925_1209"), + ("programmes", "0106_alter_ref_programme2_blank_and_null"), + ] + + operations = [ + migrations.AlterField( + model_name="programme", + name="date_achevement", + field=models.DateField(blank=True, null=True), + ), + migrations.AlterField( + model_name="programme", + name="date_achevement_compile", + field=models.DateField(blank=True, null=True), + ), + migrations.AlterField( + model_name="programme", + name="date_achevement_previsible", + field=models.DateField(blank=True, null=True), + ), + migrations.AlterField( + model_name="programme", + name="date_acte_notarie", + field=models.DateField(blank=True, null=True), + ), + migrations.AlterField( + model_name="programme", + name="date_autorisation_hors_habitat_inclusif", + field=models.DateField(blank=True, null=True), + ), + migrations.AlterField( + model_name="programme", + name="date_convention_location", + field=models.DateField(blank=True, null=True), + ), + migrations.AlterField( + model_name="programme", + name="date_residence_argement_gestionnaire_intermediation", + field=models.DateField(blank=True, null=True), + ), + migrations.AlterField( + model_name="programme", + name="departement_residence_argement_gestionnaire_intermediation", + field=models.CharField(blank=True, default="", max_length=255), + preserve_default=False, + ), + ] diff --git a/programmes/migrations/0108_alter_ref_programme4_blank_and_null.py b/programmes/migrations/0108_alter_ref_programme4_blank_and_null.py new file mode 100644 index 000000000..6ecd99a4f --- /dev/null +++ b/programmes/migrations/0108_alter_ref_programme4_blank_and_null.py @@ -0,0 +1,62 @@ +# Generated by Django 4.2.13 on 2024-09-03 20:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + atomic = False + + dependencies = [ + ("instructeurs", "0001_initial_squashed_0017_auto_20230925_1209"), + ("programmes", "0107_alter_ref_programme3_blank_and_null"), + ] + + operations = [ + migrations.AlterField( + model_name="programme", + name="edd_classique", + field=models.TextField(blank=True, default="", max_length=5000), + preserve_default=False, + ), + migrations.AlterField( + model_name="programme", + name="edd_stationnements", + field=models.TextField(blank=True, default="", max_length=5000), + preserve_default=False, + ), + migrations.AlterField( + model_name="programme", + name="edd_volumetrique", + field=models.TextField(blank=True, default="", max_length=5000), + preserve_default=False, + ), + migrations.AlterField( + model_name="programme", + name="effet_relatif", + field=models.TextField(blank=True, default=""), + preserve_default=False, + ), + migrations.AlterField( + model_name="programme", + name="mention_publication_edd_classique", + field=models.TextField(blank=True, default="", max_length=5000), + preserve_default=False, + ), + migrations.AlterField( + model_name="programme", + name="mention_publication_edd_volumetrique", + field=models.TextField(blank=True, default="", max_length=5000), + preserve_default=False, + ), + migrations.AlterField( + model_name="programme", + name="nb_bureaux", + field=models.IntegerField(blank=True, null=True), + ), + migrations.AlterField( + model_name="programme", + name="nb_locaux_commerciaux", + field=models.IntegerField(blank=True, null=True), + ), + ] diff --git a/programmes/migrations/0109_alter_ref_programme5_blank_and_null.py b/programmes/migrations/0109_alter_ref_programme5_blank_and_null.py new file mode 100644 index 000000000..e617bc19c --- /dev/null +++ b/programmes/migrations/0109_alter_ref_programme5_blank_and_null.py @@ -0,0 +1,36 @@ +# Generated by Django 4.2.13 on 2024-09-03 20:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + atomic = False + + dependencies = [ + ("instructeurs", "0001_initial_squashed_0017_auto_20230925_1209"), + ("programmes", "0108_alter_ref_programme4_blank_and_null"), + ] + + operations = [ + migrations.RunSQL( + "UPDATE programmes_programme SET numero_operation = '' WHERE" + " numero_operation IS NULL;", + migrations.RunSQL.noop, + ), + migrations.RunSQL( + "UPDATE programmes_programme SET numero_operation_pour_recherche = '' WHERE" + " numero_operation_pour_recherche IS NULL;", + migrations.RunSQL.noop, + ), + migrations.AlterField( + model_name="programme", + name="numero_operation", + field=models.CharField(blank=True, max_length=255), + ), + migrations.AlterField( + model_name="programme", + name="numero_operation_pour_recherche", + field=models.CharField(blank=True, max_length=255), + ), + ] diff --git a/programmes/migrations/0110_alter_ref_programme6_blank_and_null.py b/programmes/migrations/0110_alter_ref_programme6_blank_and_null.py new file mode 100644 index 000000000..3315b5c1b --- /dev/null +++ b/programmes/migrations/0110_alter_ref_programme6_blank_and_null.py @@ -0,0 +1,144 @@ +# Generated by Django 4.2.13 on 2024-09-03 20:37 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + atomic = False + + dependencies = [ + ("instructeurs", "0001_initial_squashed_0017_auto_20230925_1209"), + ("programmes", "0109_alter_ref_programme5_blank_and_null"), + ] + + operations = [ + migrations.AlterField( + model_name="programme", + name="parent", + field=models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + to="programmes.programme", + ), + ), + migrations.RunSQL( + "UPDATE programmes_programme SET permis_construire = '' WHERE" + " permis_construire IS NULL;", + migrations.RunSQL.noop, + ), + migrations.AlterField( + model_name="programme", + name="permis_construire", + field=models.CharField(blank=True, max_length=255), + ), + migrations.AlterField( + model_name="programme", + name="reassign_command_old_admin_backup", + field=models.IntegerField(blank=True, null=True), + ), + migrations.RunSQL( + "UPDATE programmes_programme SET reference_cadastrale = '' WHERE" + " reference_cadastrale IS NULL;", + migrations.RunSQL.noop, + ), + migrations.AlterField( + model_name="programme", + name="reference_cadastrale", + field=models.TextField(blank=True), + ), + migrations.RunSQL( + "UPDATE programmes_programme SET reference_notaire = '' WHERE" + " reference_notaire IS NULL;", + migrations.RunSQL.noop, + ), + migrations.AlterField( + model_name="programme", + name="reference_notaire", + field=models.TextField(blank=True), + ), + migrations.RunSQL( + "UPDATE programmes_programme SET reference_publication_acte = '' WHERE" + " reference_publication_acte IS NULL;", + migrations.RunSQL.noop, + ), + migrations.AlterField( + model_name="programme", + name="reference_publication_acte", + field=models.TextField(blank=True), + ), + migrations.AlterField( + model_name="programme", + name="surface_corrigee_totale", + field=models.DecimalField( + blank=True, decimal_places=2, max_digits=10, null=True + ), + ), + migrations.AlterField( + model_name="programme", + name="surface_utile_totale", + field=models.DecimalField( + blank=True, decimal_places=2, max_digits=10, null=True + ), + ), + migrations.RunSQL( + "UPDATE programmes_programme SET vendeur = '' WHERE" " vendeur IS NULL;", + migrations.RunSQL.noop, + ), + migrations.AlterField( + model_name="programme", + name="vendeur", + field=models.TextField(blank=True), + ), + migrations.RunSQL( + "UPDATE programmes_programme SET ville = '' WHERE" " ville IS NULL;", + migrations.RunSQL.noop, + ), + migrations.AlterField( + model_name="programme", + name="ville", + field=models.CharField(blank=True, max_length=255), + ), + migrations.RunSQL( + "UPDATE programmes_programme SET" + " ville_signature_residence_agrement_gestionnaire_intermediation = '' WHERE" + " ville_signature_residence_agrement_gestionnaire_intermediation IS NULL;", + migrations.RunSQL.noop, + ), + migrations.AlterField( + model_name="programme", + name="ville_signature_residence_agrement_gestionnaire_intermediation", + field=models.CharField(blank=True, max_length=255), + ), + migrations.AlterField( + model_name="programme", + name="zone_123", + field=models.CharField( + blank=True, + choices=[("1", "01"), ("2", "02"), ("3", "03"), ("1bis", "1bis")], + default=None, + max_length=25, + null=True, + ), + ), + migrations.AlterField( + model_name="programme", + name="zone_abc", + field=models.CharField( + blank=True, + choices=[ + ("A", "A"), + ("Abis", "Abis"), + ("B1", "B1"), + ("B2", "B2"), + ("C", "C"), + ("DROM", "DROM"), + ], + default=None, + max_length=25, + null=True, + ), + ), + ] diff --git a/programmes/migrations/0102_historicalprogramme.py b/programmes/migrations/0111_historicalprogramme.py similarity index 71% rename from programmes/migrations/0102_historicalprogramme.py rename to programmes/migrations/0111_historicalprogramme.py index a74e04cc7..2d6bdca6c 100644 --- a/programmes/migrations/0102_historicalprogramme.py +++ b/programmes/migrations/0111_historicalprogramme.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.13 on 2024-09-03 19:58 +# Generated by Django 4.2.13 on 2024-09-04 11:51 import uuid @@ -13,7 +13,7 @@ class Migration(migrations.Migration): dependencies = [ ("bailleurs", "0001_initial_squashed_0027_remove_search_vector_trigger"), ("instructeurs", "0001_initial_squashed_0017_auto_20230925_1209"), - ("programmes", "0101_programme_reassign_command_old_admin_backup"), + ("programmes", "0110_alter_ref_programme6_blank_and_null"), ] operations = [ @@ -23,22 +23,26 @@ class Migration(migrations.Migration): ("id", models.IntegerField(blank=True, db_index=True)), ("uuid", models.UUIDField(default=uuid.uuid4, editable=False)), ("nom", models.CharField(max_length=255)), - ("numero_operation", models.CharField(max_length=255, null=True)), + ("numero_operation", models.CharField(blank=True, max_length=255)), ( "numero_operation_pour_recherche", - models.CharField(max_length=255, null=True), + models.CharField(blank=True, max_length=255), ), ("seconde_vie", models.BooleanField(default=False)), - ("adresse", models.TextField(blank=True, null=True)), - ("code_postal", models.CharField(blank=True, max_length=5, null=True)), - ("ville", models.CharField(blank=True, max_length=255, null=True)), - ("code_insee_commune", models.CharField(max_length=10, null=True)), - ("code_insee_departement", models.CharField(max_length=10, null=True)), - ("code_insee_region", models.CharField(max_length=10, null=True)), - ("annee_gestion_programmation", models.IntegerField(null=True)), + ("adresse", models.TextField(blank=True)), + ("code_postal", models.CharField(blank=True, max_length=5)), + ("ville", models.CharField(blank=True, max_length=255)), + ("code_insee_commune", models.CharField(blank=True, max_length=10)), + ("code_insee_departement", models.CharField(blank=True, max_length=10)), + ("code_insee_region", models.CharField(blank=True, max_length=10)), + ( + "annee_gestion_programmation", + models.IntegerField(blank=True, null=True), + ), ( "zone_123", models.CharField( + blank=True, choices=[ ("1", "01"), ("2", "02"), @@ -53,6 +57,7 @@ class Migration(migrations.Migration): ( "zone_abc", models.CharField( + blank=True, choices=[ ("A", "A"), ("Abis", "Abis"), @@ -68,11 +73,15 @@ class Migration(migrations.Migration): ), ( "surface_utile_totale", - models.DecimalField(decimal_places=2, max_digits=10, null=True), + models.DecimalField( + blank=True, decimal_places=2, max_digits=10, null=True + ), ), ( "surface_corrigee_totale", - models.DecimalField(decimal_places=2, max_digits=10, null=True), + models.DecimalField( + blank=True, decimal_places=2, max_digits=10, null=True + ), ), ( "type_operation", @@ -113,54 +122,51 @@ class Migration(migrations.Migration): ), ), ("anru", models.BooleanField(default=False)), - ("nb_locaux_commerciaux", models.IntegerField(null=True)), - ("nb_bureaux", models.IntegerField(null=True)), - ("autres_locaux_hors_convention", models.TextField(null=True)), - ("vendeur", models.TextField(null=True)), - ("acquereur", models.TextField(null=True)), - ("date_acte_notarie", models.DateField(null=True)), - ("reference_notaire", models.TextField(null=True)), - ("reference_publication_acte", models.TextField(null=True)), - ("acte_de_propriete", models.TextField(null=True)), - ("effet_relatif", models.TextField(null=True)), - ("certificat_adressage", models.TextField(null=True)), - ("reference_cadastrale", models.TextField(null=True)), - ("edd_volumetrique", models.TextField(max_length=5000, null=True)), + ("nb_locaux_commerciaux", models.IntegerField(blank=True, null=True)), + ("nb_bureaux", models.IntegerField(blank=True, null=True)), + ("autres_locaux_hors_convention", models.TextField(blank=True)), + ("vendeur", models.TextField(blank=True)), + ("acquereur", models.TextField(blank=True)), + ("date_acte_notarie", models.DateField(blank=True, null=True)), + ("reference_notaire", models.TextField(blank=True)), + ("reference_publication_acte", models.TextField(blank=True)), + ("acte_de_propriete", models.TextField(blank=True)), + ("effet_relatif", models.TextField(blank=True)), + ("certificat_adressage", models.TextField(blank=True)), + ("reference_cadastrale", models.TextField(blank=True)), + ("edd_volumetrique", models.TextField(blank=True, max_length=5000)), ( "mention_publication_edd_volumetrique", - models.TextField(max_length=5000, null=True), + models.TextField(blank=True, max_length=5000), ), - ("edd_classique", models.TextField(max_length=5000, null=True)), + ("edd_classique", models.TextField(blank=True, max_length=5000)), ( "mention_publication_edd_classique", - models.TextField(max_length=5000, null=True), - ), - ( - "edd_stationnements", - models.TextField(blank=True, max_length=5000, null=True), + models.TextField(blank=True, max_length=5000), ), - ("permis_construire", models.CharField(max_length=255, null=True)), - ("date_achevement_previsible", models.DateField(null=True)), - ("date_achat", models.DateField(null=True)), - ("date_achevement", models.DateField(null=True)), + ("edd_stationnements", models.TextField(blank=True, max_length=5000)), + ("permis_construire", models.CharField(blank=True, max_length=255)), + ("date_achevement_previsible", models.DateField(blank=True, null=True)), + ("date_achat", models.DateField(blank=True, null=True)), + ("date_achevement", models.DateField(blank=True, null=True)), ( "date_autorisation_hors_habitat_inclusif", - models.DateField(null=True), + models.DateField(blank=True, null=True), ), - ("date_convention_location", models.DateField(null=True)), + ("date_convention_location", models.DateField(blank=True, null=True)), ( "date_residence_argement_gestionnaire_intermediation", - models.DateField(null=True), + models.DateField(blank=True, null=True), ), ( "departement_residence_argement_gestionnaire_intermediation", - models.CharField(max_length=255, null=True), + models.CharField(blank=True, max_length=255), ), ( "ville_signature_residence_agrement_gestionnaire_intermediation", - models.CharField(max_length=255, null=True), + models.CharField(blank=True, max_length=255), ), - ("date_achevement_compile", models.DateField(null=True)), + ("date_achevement_compile", models.DateField(blank=True, null=True)), ("cree_le", models.DateTimeField(blank=True, editable=False)), ("mis_a_jour_le", models.DateTimeField(blank=True, editable=False)), ( @@ -169,7 +175,10 @@ class Migration(migrations.Migration): blank=True, null=True ), ), - ("reassign_command_old_admin_backup", models.IntegerField(null=True)), + ( + "reassign_command_old_admin_backup", + models.IntegerField(blank=True, null=True), + ), ("history_user_id", models.IntegerField(null=True)), ("history_id", models.AutoField(primary_key=True, serialize=False)), ("history_date", models.DateTimeField(db_index=True)), diff --git a/programmes/models/models.py b/programmes/models/models.py index 51c5f1895..ab0dc07b6 100644 --- a/programmes/models/models.py +++ b/programmes/models/models.py @@ -50,11 +50,12 @@ class Meta: "self", on_delete=models.CASCADE, null=True, + blank=True, ) uuid = models.UUIDField(default=uuid.uuid4, editable=False) nom = models.CharField(max_length=255) - numero_operation = models.CharField(max_length=255, null=True) - numero_operation_pour_recherche = models.CharField(max_length=255, null=True) + numero_operation = models.CharField(max_length=255, blank=True) + numero_operation_pour_recherche = models.CharField(max_length=255, blank=True) seconde_vie = models.BooleanField(default=False) bailleur = models.ForeignKey( "bailleurs.Bailleur", @@ -62,34 +63,36 @@ class Meta: null=False, ) administration = models.ForeignKey( - "instructeurs.Administration", on_delete=models.SET_NULL, null=True + "instructeurs.Administration", on_delete=models.SET_NULL, null=True, blank=True ) - adresse = models.TextField(null=True, blank=True) - code_postal = models.CharField(max_length=5, null=True, blank=True) - ville = models.CharField(max_length=255, null=True, blank=True) - code_insee_commune = models.CharField(max_length=10, null=True) - code_insee_departement = models.CharField(max_length=10, null=True) - code_insee_region = models.CharField(max_length=10, null=True) - annee_gestion_programmation = models.IntegerField(null=True) + adresse = models.TextField(blank=True) + code_postal = models.CharField(max_length=5, blank=True) + ville = models.CharField(max_length=255, blank=True) + code_insee_commune = models.CharField(max_length=10, blank=True) + code_insee_departement = models.CharField(max_length=10, blank=True) + code_insee_region = models.CharField(max_length=10, blank=True) + annee_gestion_programmation = models.IntegerField(null=True, blank=True) zone_123 = models.CharField( max_length=25, choices=Zone123.choices, default=None, null=True, + blank=True, ) zone_abc = models.CharField( max_length=25, choices=ZoneABC.choices, default=None, null=True, + blank=True, ) surface_utile_totale = models.DecimalField( - max_digits=10, decimal_places=2, null=True + max_digits=10, decimal_places=2, null=True, blank=True ) surface_corrigee_totale = models.DecimalField( - max_digits=10, decimal_places=2, null=True + max_digits=10, decimal_places=2, null=True, blank=True ) type_operation = models.CharField( max_length=25, @@ -102,46 +105,50 @@ class Meta: default=NatureLogement.LOGEMENTSORDINAIRES, ) anru = models.BooleanField(default=False) - nb_locaux_commerciaux = models.IntegerField(null=True) - nb_bureaux = models.IntegerField(null=True) - autres_locaux_hors_convention = models.TextField(null=True) - vendeur = models.TextField(null=True) - acquereur = models.TextField(null=True) - date_acte_notarie = models.DateField(null=True) - reference_notaire = models.TextField(null=True) - reference_publication_acte = models.TextField(null=True) - acte_de_propriete = models.TextField(null=True) - effet_relatif = models.TextField(null=True) - certificat_adressage = models.TextField(null=True) - reference_cadastrale = models.TextField(null=True) - edd_volumetrique = models.TextField(max_length=5000, null=True) - mention_publication_edd_volumetrique = models.TextField(max_length=5000, null=True) - edd_classique = models.TextField(max_length=5000, null=True) - mention_publication_edd_classique = models.TextField(max_length=5000, null=True) - edd_stationnements = models.TextField(max_length=5000, null=True, blank=True) - permis_construire = models.CharField(max_length=255, null=True) - date_achevement_previsible = models.DateField(null=True) - date_achat = models.DateField(null=True) - date_achevement = models.DateField(null=True) - date_autorisation_hors_habitat_inclusif = models.DateField(null=True) # FOYER - date_convention_location = models.DateField(null=True) # FOYER & RESIDENCE + nb_locaux_commerciaux = models.IntegerField(null=True, blank=True) + nb_bureaux = models.IntegerField(null=True, blank=True) + autres_locaux_hors_convention = models.TextField(blank=True) + vendeur = models.TextField(blank=True) + acquereur = models.TextField(blank=True) + date_acte_notarie = models.DateField(null=True, blank=True) + reference_notaire = models.TextField(blank=True) + reference_publication_acte = models.TextField(blank=True) + acte_de_propriete = models.TextField(blank=True) + effet_relatif = models.TextField(blank=True) + certificat_adressage = models.TextField(blank=True) + reference_cadastrale = models.TextField(blank=True) + edd_volumetrique = models.TextField(max_length=5000, blank=True) + mention_publication_edd_volumetrique = models.TextField(max_length=5000, blank=True) + edd_classique = models.TextField(max_length=5000, blank=True) + mention_publication_edd_classique = models.TextField(max_length=5000, blank=True) + edd_stationnements = models.TextField(max_length=5000, blank=True) + permis_construire = models.CharField(max_length=255, blank=True) + date_achevement_previsible = models.DateField(null=True, blank=True) + date_achat = models.DateField(null=True, blank=True) + date_achevement = models.DateField(null=True, blank=True) + date_autorisation_hors_habitat_inclusif = models.DateField( + null=True, blank=True + ) # FOYER + date_convention_location = models.DateField( + null=True, blank=True + ) # FOYER & RESIDENCE date_residence_argement_gestionnaire_intermediation = models.DateField( - null=True + null=True, blank=True ) # RESIDENCE departement_residence_argement_gestionnaire_intermediation = models.CharField( - null=True, max_length=255 + blank=True, max_length=255 ) # RESIDENCE ville_signature_residence_agrement_gestionnaire_intermediation = models.CharField( - null=True, max_length=255 + blank=True, max_length=255 ) # RESIDENCE - date_achevement_compile = models.DateField(null=True) + date_achevement_compile = models.DateField(null=True, blank=True) cree_le = models.DateTimeField(auto_now_add=True) mis_a_jour_le = models.DateTimeField(auto_now=True) search_vector = SearchVectorField(null=True, blank=True) - reassign_command_old_admin_backup = models.IntegerField(null=True) + reassign_command_old_admin_backup = models.IntegerField(null=True, blank=True) history = HistoricalRecords( history_user_id_field=models.IntegerField(null=True), @@ -327,7 +334,7 @@ class LogementEDD(models.Model): choices=FinancementEDD.choices, default=FinancementEDD.PLUS, ) - numero_lot = models.CharField(max_length=255, null=True) + numero_lot = models.CharField(max_length=255, blank=True) cree_le = models.DateTimeField(auto_now_add=True) mis_a_jour_le = models.DateTimeField(auto_now=True) lot_num = 0 @@ -357,10 +364,10 @@ class ReferenceCadastrale(models.Model): null=False, related_name="referencecadastrales", ) - section = models.CharField(max_length=255, null=True) - numero = models.IntegerField(null=True) - lieudit = models.CharField(max_length=255, null=True) - surface = models.CharField(max_length=255, null=True) + section = models.CharField(max_length=255, blank=True) + numero = models.IntegerField(null=True, blank=True) + lieudit = models.CharField(max_length=255, blank=True) + surface = models.CharField(max_length=255, blank=True) cree_le = models.DateTimeField(auto_now_add=True) mis_a_jour_le = models.DateTimeField(auto_now=True) @@ -426,9 +433,10 @@ class Lot(models.Model): "self", on_delete=models.CASCADE, null=True, + blank=True, ) uuid = models.UUIDField(default=uuid.uuid4, editable=False) - nb_logements = models.IntegerField(null=True) + nb_logements = models.IntegerField(null=True, blank=True) programme = models.ForeignKey( "Programme", on_delete=models.CASCADE, null=False, related_name="lots" ) @@ -442,8 +450,8 @@ class Lot(models.Model): choices=TypeHabitat.choices, default=TypeHabitat.INDIVIDUEL, ) - edd_volumetrique = models.TextField(max_length=50000, null=True) - edd_classique = models.TextField(max_length=50000, null=True) + edd_volumetrique = models.TextField(max_length=50000, blank=True) + edd_classique = models.TextField(max_length=50000, blank=True) annexe_caves = models.BooleanField(default=False) annexe_soussols = models.BooleanField(default=False) annexe_remises = models.BooleanField(default=False) @@ -460,12 +468,14 @@ class Lot(models.Model): max_digits=6, decimal_places=2, null=True, + blank=True, verbose_name="Loyer dérogatoire", ) surface_habitable_totale = models.DecimalField( max_digits=12, decimal_places=2, null=True, + blank=True, ) surface_locaux_collectifs_residentiels = models.DecimalField( max_digits=12, @@ -598,31 +608,47 @@ class Logement(models.Model): default=TypologieLogement.T1, ) surface_habitable = models.DecimalField( - max_digits=12, decimal_places=2, null=True, verbose_name="Surface habitable" + max_digits=12, + decimal_places=2, + null=True, + blank=True, + verbose_name="Surface habitable", ) surface_corrigee = models.DecimalField( - max_digits=12, decimal_places=2, null=True, verbose_name="Surface corrigée" + max_digits=12, + decimal_places=2, + null=True, + blank=True, + verbose_name="Surface corrigée", + ) + surface_annexes = models.DecimalField( + max_digits=12, decimal_places=2, null=True, blank=True ) - surface_annexes = models.DecimalField(max_digits=12, decimal_places=2, null=True) surface_annexes_retenue = models.DecimalField( - max_digits=12, decimal_places=2, null=True + max_digits=12, decimal_places=2, null=True, blank=True ) surface_utile = models.DecimalField( - max_digits=12, decimal_places=2, null=True, verbose_name="Surface utile" + max_digits=12, + decimal_places=2, + null=True, + blank=True, + verbose_name="Surface utile", ) loyer_par_metre_carre = models.DecimalField( max_digits=12, decimal_places=2, null=True, + blank=True, verbose_name="Loyer maximum en € par m² de surface utile", ) coeficient = models.DecimalField( max_digits=12, decimal_places=4, null=True, + blank=True, verbose_name="Coefficient propre au logement", ) - loyer = models.DecimalField(max_digits=12, decimal_places=2, null=True) + loyer = models.DecimalField(max_digits=12, decimal_places=2, null=True, blank=True) cree_le = models.DateTimeField(auto_now_add=True) mis_a_jour_le = models.DateTimeField(auto_now=True) diff --git a/programmes/signals.py b/programmes/signals.py index 825759c99..0b8856fb7 100644 --- a/programmes/signals.py +++ b/programmes/signals.py @@ -11,15 +11,12 @@ @receiver(pre_save, sender=Programme) def compute_numero_operation_for_search(sender, instance, *args, **kwargs): - if instance.numero_operation is None: - instance.numero_operation_pour_recherche = None - else: - instance.numero_operation_pour_recherche = ( - instance.numero_operation.replace("/", "") - .replace("-", "") - .replace(" ", "") - .replace(".", "") - ) + instance.numero_operation_pour_recherche = ( + instance.numero_operation.replace("/", "") + .replace("-", "") + .replace(" ", "") + .replace(".", "") + ) @receiver(pre_save, sender=Programme) diff --git a/programmes/tests/test_models.py b/programmes/tests/test_models.py index 6fed66283..a43f1292d 100644 --- a/programmes/tests/test_models.py +++ b/programmes/tests/test_models.py @@ -287,8 +287,8 @@ def test_code_insee(self): bailleur=bailleur, administration=administration, ) - self.assertIsNone(programme_00.code_insee_departement) - self.assertIsNone(programme_00.code_insee_region) + self.assertEqual(programme_00.code_insee_departement, "") + self.assertEqual(programme_00.code_insee_region, "") programme_20 = Programme.objects.create( nom="test", @@ -346,10 +346,10 @@ def test_edd_stationnements_files(self): class TestProgrammeSignals: def test_numero_operation_pour_recherche_create_num_none(self): - convention = ProgrammeFactory(numero_operation=None) + convention = ProgrammeFactory(numero_operation="") - assert convention.numero_operation is None - assert convention.numero_operation_pour_recherche is None + assert convention.numero_operation == "" + assert convention.numero_operation_pour_recherche == "" def test_numero_operation_pour_recherche_create_num_alphanum(self): convention = ProgrammeFactory(numero_operation="ALPHA1230")