From e9f516ba6c0a6cc1f1aecd93cb73b3a726486bb7 Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Wed, 12 Jun 2024 09:57:22 +0200 Subject: [PATCH] Add SiaeActivity.sector_group field --- lemarche/siaes/migrations/0076_siaeactivity.py | 15 +++++++++++++-- lemarche/siaes/models.py | 12 ++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/lemarche/siaes/migrations/0076_siaeactivity.py b/lemarche/siaes/migrations/0076_siaeactivity.py index 8a9c3d80d..a13371865 100644 --- a/lemarche/siaes/migrations/0076_siaeactivity.py +++ b/lemarche/siaes/migrations/0076_siaeactivity.py @@ -10,6 +10,7 @@ class Migration(migrations.Migration): dependencies = [ ("sectors", "0003_sector_sectorgroup_ordering"), + ("perimeters", "0005_alter_perimeter_post_codes"), ("siaes", "0075_historicalsiae"), ] @@ -68,7 +69,7 @@ class Migration(migrations.Migration): blank=True, related_name="siae_activities", to="sectors.sector", - verbose_name="Secteurs d'activité", + verbose_name="Activités", ), ), ( @@ -80,13 +81,23 @@ class Migration(migrations.Migration): verbose_name="Structure", ), ), + ( + "sector_group", + models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.SET_NULL, + related_name="siae_activities", + to="sectors.sectorgroup", + verbose_name="Secteur d'activité", + ), + ), ( "location", models.ForeignKey( blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, - related_name="siae_activities_location", + related_name="siae_activities", to="perimeters.perimeter", verbose_name="Localisation", ), diff --git a/lemarche/siaes/models.py b/lemarche/siaes/models.py index a684b297e..b7ceb2dc2 100644 --- a/lemarche/siaes/models.py +++ b/lemarche/siaes/models.py @@ -1398,8 +1398,16 @@ class SiaeActivity(models.Model): "siaes.Siae", verbose_name="Structure", related_name="activities", on_delete=models.CASCADE ) + sector_group = models.ForeignKey( + "sectors.SectorGroup", + verbose_name="Secteur d'activité", + related_name="siae_activities", + on_delete=models.SET_NULL, + null=True, + # blank=True, + ) sectors = models.ManyToManyField( - "sectors.Sector", verbose_name="Secteurs d'activité", related_name="siae_activities", blank=True + "sectors.Sector", verbose_name="Activités", related_name="siae_activities", blank=True ) presta_type = ChoiceArrayField( verbose_name="Type de prestation", @@ -1411,7 +1419,7 @@ class SiaeActivity(models.Model): location: Perimeter = models.ForeignKey( to="perimeters.Perimeter", verbose_name="Localisation", - related_name="siae_activities_location", + related_name="siae_activities", on_delete=models.DO_NOTHING, blank=True, null=True,