Skip to content

Commit

Permalink
export_ads_managers: add departement number and insee code
Browse files Browse the repository at this point in the history
  • Loading branch information
brmzkw committed Feb 23, 2024
1 parent ee7da6f commit 98d217f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions mesads/app/management/commands/export_ads_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ def handle(self, *args, **options):
writer = csv.DictWriter(
sys.stdout,
fieldnames=[
"Préfecture",
"Département",
"Nom département",
"Type d'administration",
"Nom de l'administration",
"Code INSEE",
"Nombre d'ADS",
],
)
Expand All @@ -36,11 +38,13 @@ def handle(self, *args, **options):

for row in query:
prefecture = None
insee = None

if issubclass(row.content_type.model_class(), Commune):
if row.content_object.libelle == "Test MesADS":
continue
prefecture = row.content_object.departement
insee = row.content_object.insee
elif issubclass(row.content_type.model_class(), EPCI):
if row.content_object.name == "CC Test MesADS":
continue
Expand All @@ -52,9 +56,11 @@ def handle(self, *args, **options):

writer.writerow(
{
"Préfecture": prefectures[prefecture],
"Département": prefecture,
"Nom département": prefectures[prefecture],
"Type d'administration": row.content_object.type_name(),
"Nom de l'administration": row.content_object.text(),
"Code INSEE": insee,
"Nombre d'ADS": row.ads_count,
}
)

0 comments on commit 98d217f

Please sign in to comment.