Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(siae): réorganise un peu les kind constants #1076

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 11 additions & 21 deletions lemarche/siaes/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,31 @@
KIND_ESAT = "ESAT"
KIND_SEP = "SEP"

KIND_CHOICES = (
KIND_PARENT_INSERTION_NAME = "Insertion"
KIND_INSERTION_CHOICES = (
(KIND_EI, "Entreprise d'insertion"), # Regroupées au sein de la fédération des entreprises d'insertion.
(KIND_AI, "Association intermédiaire"),
(KIND_ACI, "Atelier chantier d'insertion"),
# (KIND_ACIPHC, "Atelier chantier d'insertion premières heures en chantier"),
(KIND_ETTI, "Entreprise de travail temporaire d'insertion"),
(KIND_EITI, "Entreprise d'insertion par le travail indépendant"),
(KIND_GEIQ, "Groupement d'employeurs pour l'insertion et la qualification"),
(KIND_EA, "Entreprise adaptée"),
(KIND_EATT, "Entreprise adaptée de travail temporaire"),
(KIND_ESAT, "Etablissement et service d'aide par le travail"),
(KIND_SEP, "Produits et services réalisés en prison"),
)
# KIND_CHOICES_WITH_EXTRA = ((key, f"{value} ({key})") for (key, value) in KIND_CHOICES)
KIND_CHOICES_WITH_EXTRA_INSERTION = (
(KIND_EI, "Entreprise d'insertion (EI)"), # Regroupées au sein de la fédération des entreprises d'insertion.
(KIND_AI, "Association intermédiaire (AI)"),
(KIND_ACI, "Atelier chantier d'insertion (ACI)"),
# (KIND_ACIPHC, "Atelier chantier d'insertion premières heures en chantier (ACIPHC)"),
(KIND_ETTI, "Entreprise de travail temporaire d'insertion (ETTI)"),
(KIND_EITI, "Entreprise d'insertion par le travail indépendant (EITI)"),
(KIND_GEIQ, "Groupement d'employeurs pour l'insertion et la qualification (GEIQ)"),
(KIND_SEP, "Produits et services réalisés en prison"), # (SEP) ne s'applique pas à toutes les structures
)
KIND_CHOICES_WITH_EXTRA_HANDICAP = (
KIND_INSERTION_CHOICES_WITH_EXTRA = [(key, f"{value} ({key})") for (key, value) in KIND_INSERTION_CHOICES]
KIND_INSERTION_LIST = [k[0] for k in KIND_INSERTION_CHOICES]

KIND_PARENT_HANDICAP_NAME = "Handicap"
KIND_HANDICAP_CHOICES = (
(KIND_EA, "Entreprise adaptée (EA)"),
(KIND_EATT, "Entreprise adaptée de travail temporaire (EATT)"),
(KIND_ESAT, "Etablissement et service d'aide par le travail (ESAT)"),
)
KIND_CHOICES_WITH_EXTRA = KIND_CHOICES_WITH_EXTRA_INSERTION + KIND_CHOICES_WITH_EXTRA_HANDICAP
KIND_HANDICAP_CHOICES_WITH_EXTRA = [(key, f"{value} ({key})") for (key, value) in KIND_HANDICAP_CHOICES]
KIND_HANDICAP_LIST = [k[0] for k in KIND_HANDICAP_CHOICES]

KIND_GROUP_INSERTION_NAME = "Insertion"
KIND_GROUP_INSERTION_LIST = [k[0] for k in KIND_CHOICES_WITH_EXTRA_INSERTION]
KIND_GROUP_HANDICAP_NAME = "Handicap"
KIND_GROUP_HANDICAP_LIST = [k[0] for k in KIND_CHOICES_WITH_EXTRA_HANDICAP]
KIND_CHOICES = KIND_INSERTION_CHOICES + KIND_HANDICAP_CHOICES
KIND_CHOICES_WITH_EXTRA = KIND_INSERTION_CHOICES_WITH_EXTRA + KIND_HANDICAP_CHOICES_WITH_EXTRA

PRESTA_DISP = "DISP"
PRESTA_PREST = "PREST"
Expand Down
34 changes: 34 additions & 0 deletions lemarche/siaes/migrations/0070_alter_siae_kind.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 4.2.9 on 2024-02-09 14:47

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("siaes", "0069_siae_super_badge_fields"),
]

operations = [
migrations.AlterField(
model_name="siae",
name="kind",
field=models.CharField(
choices=[
("EI", "Entreprise d'insertion (EI)"),
("AI", "Association intermédiaire (AI)"),
("ACI", "Atelier chantier d'insertion (ACI)"),
("ETTI", "Entreprise de travail temporaire d'insertion (ETTI)"),
("EITI", "Entreprise d'insertion par le travail indépendant (EITI)"),
("GEIQ", "Groupement d'employeurs pour l'insertion et la qualification (GEIQ)"),
("SEP", "Produits et services réalisés en prison (SEP)"),
("EA", "Entreprise adaptée (EA) (EA)"),
("EATT", "Entreprise adaptée de travail temporaire (EATT) (EATT)"),
("ESAT", "Etablissement et service d'aide par le travail (ESAT) (ESAT)"),
],
db_index=True,
default="EI",
max_length=6,
verbose_name="Type de structure",
),
),
]
8 changes: 4 additions & 4 deletions lemarche/siaes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,10 +953,10 @@ def kind_is_esat_or_ea_or_eatt(self) -> bool:

@property
def kind_parent(self) -> str:
if self.kind in siae_constants.KIND_GROUP_INSERTION_LIST:
return siae_constants.KIND_GROUP_INSERTION_NAME
if self.kind in siae_constants.KIND_GROUP_HANDICAP_LIST:
return siae_constants.KIND_GROUP_HANDICAP_NAME
if self.kind in siae_constants.KIND_INSERTION_LIST:
return siae_constants.KIND_PARENT_INSERTION_NAME
if self.kind in siae_constants.KIND_HANDICAP_LIST:
return siae_constants.KIND_PARENT_HANDICAP_NAME
return ""

@property
Expand Down
32 changes: 32 additions & 0 deletions lemarche/stats/migrations/0009_alter_tracker_siae_kind.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 4.2.9 on 2024-02-09 14:47

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("stats", "0008_alter_tracker_user_kind"),
]

operations = [
migrations.AlterField(
model_name="tracker",
name="siae_kind",
field=models.CharField(
blank=True,
choices=[
("EI", "Entreprise d'insertion (EI)"),
("AI", "Association intermédiaire (AI)"),
("ACI", "Atelier chantier d'insertion (ACI)"),
("ETTI", "Entreprise de travail temporaire d'insertion (ETTI)"),
("EITI", "Entreprise d'insertion par le travail indépendant (EITI)"),
("GEIQ", "Groupement d'employeurs pour l'insertion et la qualification (GEIQ)"),
("SEP", "Produits et services réalisés en prison (SEP)"),
("EA", "Entreprise adaptée (EA) (EA)"),
("EATT", "Entreprise adaptée de travail temporaire (EATT) (EATT)"),
("ESAT", "Etablissement et service d'aide par le travail (ESAT) (ESAT)"),
],
max_length=6,
),
),
]
39 changes: 39 additions & 0 deletions lemarche/tenders/migrations/0074_alter_tender_siae_kind.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Generated by Django 4.2.9 on 2024-02-09 14:47

from django.db import migrations, models

import lemarche.utils.fields


class Migration(migrations.Migration):
dependencies = [
("tenders", "0073_tendersiae_survey_transactioned_amount_and_more"),
]

operations = [
migrations.AlterField(
model_name="tender",
name="siae_kind",
field=lemarche.utils.fields.ChoiceArrayField(
base_field=models.CharField(
choices=[
("EI", "Entreprise d'insertion"),
("AI", "Association intermédiaire"),
("ACI", "Atelier chantier d'insertion"),
("ETTI", "Entreprise de travail temporaire d'insertion"),
("EITI", "Entreprise d'insertion par le travail indépendant"),
("GEIQ", "Groupement d'employeurs pour l'insertion et la qualification"),
("SEP", "Produits et services réalisés en prison"),
("EA", "Entreprise adaptée (EA)"),
("EATT", "Entreprise adaptée de travail temporaire (EATT)"),
("ESAT", "Etablissement et service d'aide par le travail (ESAT)"),
],
max_length=20,
),
blank=True,
default=list,
size=None,
verbose_name="Type de structure",
),
),
]
4 changes: 2 additions & 2 deletions lemarche/www/siaes/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@


FORM_KIND_CHOICES_GROUPED = (
("Insertion par l'activité économique", siae_constants.KIND_CHOICES_WITH_EXTRA_INSERTION),
("Handicap", siae_constants.KIND_CHOICES_WITH_EXTRA_HANDICAP),
("Insertion par l'activité économique", siae_constants.KIND_INSERTION_CHOICES_WITH_EXTRA),
("Handicap", siae_constants.KIND_HANDICAP_CHOICES_WITH_EXTRA),
)
FORM_TERRITORY_CHOICES = (
("QPV", "Quartier prioritaire de la politique de la ville (QPV)"),
Expand Down
Loading