Capitalisation des constantes
This commit is contained in:
@@ -3,9 +3,9 @@ import os
|
||||
from dash import dcc, html, register_page
|
||||
|
||||
from src.figures import get_sources_tables
|
||||
from src.utils import meta_content
|
||||
from src.old_utils import META_CONTENT
|
||||
|
||||
name = "À propos"
|
||||
NAME = "À propos"
|
||||
|
||||
register_page(
|
||||
__name__,
|
||||
@@ -13,14 +13,14 @@ register_page(
|
||||
title="À propos | decp.info",
|
||||
name="À propos",
|
||||
description="En savoir plus sur decp.info, l'outil d'exploration des données essentielles de la commande publique.",
|
||||
image_url=meta_content["image_url"],
|
||||
image_url=META_CONTENT["image_url"],
|
||||
order=5,
|
||||
)
|
||||
|
||||
layout = html.Div(
|
||||
className="container",
|
||||
children=[
|
||||
html.H2(name),
|
||||
html.H2(NAME),
|
||||
html.Div(
|
||||
className="a-propos-container",
|
||||
children=[
|
||||
|
||||
+11
-11
@@ -24,23 +24,23 @@ from src.figures import (
|
||||
make_column_picker,
|
||||
point_on_map,
|
||||
)
|
||||
from src.utils import (
|
||||
columns,
|
||||
df_acheteurs,
|
||||
from src.old_utils import (
|
||||
COLUMNS,
|
||||
DF_ACHETEURS,
|
||||
META_CONTENT,
|
||||
filter_table_data,
|
||||
format_number,
|
||||
get_annuaire_data,
|
||||
get_button_properties,
|
||||
get_default_hidden_columns,
|
||||
get_departement_region,
|
||||
meta_content,
|
||||
prepare_table_data,
|
||||
sort_table_data,
|
||||
)
|
||||
|
||||
|
||||
def get_title(acheteur_id: str | None = None) -> str:
|
||||
acheteur_nom = df_acheteurs.filter(pl.col("acheteur_id") == acheteur_id).select(
|
||||
acheteur_nom = DF_ACHETEURS.filter(pl.col("acheteur_id") == acheteur_id).select(
|
||||
"acheteur_nom"
|
||||
)
|
||||
if acheteur_nom.height > 0:
|
||||
@@ -54,11 +54,11 @@ register_page(
|
||||
title=get_title,
|
||||
name="Acheteur",
|
||||
description="Consultez les marchés publics attribués par cet acheteur.",
|
||||
image_url=meta_content["image_url"],
|
||||
image_url=META_CONTENT["image_url"],
|
||||
order=5,
|
||||
)
|
||||
|
||||
datatable = html.Div(
|
||||
DATATABLE = html.Div(
|
||||
className="marches_table",
|
||||
children=DataTable(
|
||||
dtid="acheteur_datatable",
|
||||
@@ -229,7 +229,7 @@ layout = [
|
||||
scrollable=True,
|
||||
size="xl",
|
||||
),
|
||||
datatable,
|
||||
DATATABLE,
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -460,8 +460,8 @@ clientside_callback(
|
||||
)
|
||||
def update_hidden_columns_from_checkboxes(selected_columns):
|
||||
if selected_columns:
|
||||
selected_columns = [columns[i] for i in selected_columns]
|
||||
hidden_columns = [col for col in columns if col not in selected_columns]
|
||||
selected_columns = [COLUMNS[i] for i in selected_columns]
|
||||
hidden_columns = [col for col in COLUMNS if col not in selected_columns]
|
||||
return hidden_columns
|
||||
else:
|
||||
return []
|
||||
@@ -489,7 +489,7 @@ def update_checkboxes_from_hidden_columns(hidden_cols, current_checkboxes):
|
||||
hidden_cols = hidden_cols or get_default_hidden_columns("acheteur")
|
||||
|
||||
# Show all columns that are NOT hidden
|
||||
visible_cols = [columns.index(col) for col in columns if col not in hidden_cols]
|
||||
visible_cols = [COLUMNS.index(col) for col in COLUMNS if col not in hidden_cols]
|
||||
return visible_cols
|
||||
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
from dash import Input, Output, callback, dcc, html, register_page
|
||||
|
||||
from src.db import get_cursor
|
||||
from src.utils import departements
|
||||
from src.old_utils import DEPARTEMENTS
|
||||
|
||||
name = "Département"
|
||||
NAME = "Département"
|
||||
|
||||
|
||||
def get_title(code):
|
||||
return f"Marchés publics de {departements[code]['departement']} | decp.info"
|
||||
return f"Marchés publics de {DEPARTEMENTS[code]['departement']} | decp.info"
|
||||
|
||||
|
||||
def get_description(code):
|
||||
return f"Marchés publics passés dans le département {departements[code]['departement']} | decp.info"
|
||||
return f"Marchés publics passés dans le département {DEPARTEMENTS[code]['departement']} | decp.info"
|
||||
|
||||
|
||||
register_page(
|
||||
@@ -20,7 +20,7 @@ register_page(
|
||||
title=get_title,
|
||||
description=get_description,
|
||||
order=50,
|
||||
name=name,
|
||||
name=NAME,
|
||||
)
|
||||
|
||||
layout = html.Div(
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from dash import dcc, html, register_page
|
||||
|
||||
from src.utils import departements
|
||||
from src.old_utils import DEPARTEMENTS
|
||||
|
||||
name = "Départements"
|
||||
NAME = "Départements"
|
||||
|
||||
register_page(
|
||||
__name__,
|
||||
@@ -18,7 +18,7 @@ layout = html.Div(
|
||||
html.Ul(
|
||||
[
|
||||
html.Li(dcc.Link(d["departement"], href=f"/departements/{k}"))
|
||||
for k, d in departements.items()
|
||||
for k, d in DEPARTEMENTS.items()
|
||||
]
|
||||
),
|
||||
]
|
||||
|
||||
@@ -2,17 +2,17 @@ import polars as pl
|
||||
from dash import Input, Output, callback, dcc, html, register_page
|
||||
|
||||
from src.db import get_cursor
|
||||
from src.utils import df_acheteurs, df_titulaires
|
||||
from src.old_utils import DF_ACHETEURS, DF_TITULAIRES
|
||||
|
||||
name = "Liste des marchés publics"
|
||||
NAME = "Liste des marchés publics"
|
||||
|
||||
|
||||
def make_org_nom_verbe(org_type, org_id) -> tuple:
|
||||
if org_type == "titulaire":
|
||||
df = df_titulaires
|
||||
df = DF_TITULAIRES
|
||||
verbe = "remportés"
|
||||
elif org_type == "acheteur":
|
||||
df = df_acheteurs
|
||||
df = DF_ACHETEURS
|
||||
verbe = "attribués"
|
||||
else:
|
||||
raise ValueError
|
||||
@@ -44,7 +44,7 @@ register_page(
|
||||
title=get_title,
|
||||
description=get_description,
|
||||
order=40,
|
||||
name=name,
|
||||
name=NAME,
|
||||
)
|
||||
|
||||
layout = html.Div(
|
||||
|
||||
+5
-5
@@ -6,11 +6,11 @@ from dash import Input, Output, callback, dcc, html, register_page
|
||||
from polars import selectors as cs
|
||||
|
||||
from src.db import query_marches
|
||||
from src.utils import (
|
||||
data_schema,
|
||||
from src.old_utils import (
|
||||
DATA_SCHEMA,
|
||||
META_CONTENT,
|
||||
format_values,
|
||||
make_org_jsonld,
|
||||
meta_content,
|
||||
unformat_montant,
|
||||
)
|
||||
|
||||
@@ -25,7 +25,7 @@ register_page(
|
||||
title=get_title,
|
||||
name="Marché",
|
||||
description="Consultez les détails de ce marché public : montant, acheteur, titulaires, modifications, etc.",
|
||||
image_url=meta_content["image_url"],
|
||||
image_url=META_CONTENT["image_url"],
|
||||
order=7,
|
||||
)
|
||||
|
||||
@@ -110,7 +110,7 @@ def get_marche_data(url) -> tuple[dict, list]:
|
||||
)
|
||||
def update_marche_info(marche, titulaires):
|
||||
def make_parameter(col, bold=True):
|
||||
column_object = data_schema.get(col)
|
||||
column_object = DATA_SCHEMA.get(col)
|
||||
column_name = column_object.get("title") if column_object else col
|
||||
|
||||
if marche[col]:
|
||||
|
||||
+27
-27
@@ -30,45 +30,45 @@ from src.figures import (
|
||||
make_column_picker,
|
||||
make_donut,
|
||||
)
|
||||
from src.utils import (
|
||||
columns,
|
||||
departements,
|
||||
df_acheteurs,
|
||||
df_titulaires,
|
||||
from src.old_utils import (
|
||||
COLUMNS,
|
||||
DEPARTEMENTS,
|
||||
DF_ACHETEURS,
|
||||
DF_TITULAIRES,
|
||||
META_CONTENT,
|
||||
get_default_hidden_columns,
|
||||
get_enum_values_as_dict,
|
||||
logger,
|
||||
meta_content,
|
||||
prepare_dashboard_data,
|
||||
prepare_table_data,
|
||||
)
|
||||
|
||||
name = "Observatoire"
|
||||
NAME = "Observatoire"
|
||||
|
||||
register_page(
|
||||
__name__,
|
||||
path="/observatoire",
|
||||
title="Observatoire | decp.info",
|
||||
name=name,
|
||||
name=NAME,
|
||||
description="Visualisez l'état de la publication des données essentielles des marchés publics en France.",
|
||||
image_url=meta_content["image_url"],
|
||||
image_url=META_CONTENT["image_url"],
|
||||
order=3,
|
||||
)
|
||||
options_years = []
|
||||
OPTIONS_YEARS = []
|
||||
for year in reversed(range(2017, datetime.now().year + 1)):
|
||||
option_year = {
|
||||
"label": str(year),
|
||||
"value": year,
|
||||
}
|
||||
options_years.append(option_year)
|
||||
OPTIONS_YEARS.append(option_year)
|
||||
|
||||
options_departements = []
|
||||
for code in departements.keys():
|
||||
OPTIONS_DEPARTEMENTS = []
|
||||
for code in DEPARTEMENTS.keys():
|
||||
departement = {
|
||||
"label": f"{departements[code]['departement']} ({code})",
|
||||
"label": f"{DEPARTEMENTS[code]['departement']} ({code})",
|
||||
"value": code,
|
||||
}
|
||||
options_departements.append(departement)
|
||||
OPTIONS_DEPARTEMENTS.append(departement)
|
||||
|
||||
OBSERVATOIRE_COLUMNS = [
|
||||
col
|
||||
@@ -124,7 +124,7 @@ Alors, on fait comment ?
|
||||
html.Div(
|
||||
className="container-fluid",
|
||||
children=[
|
||||
html.H2(children=[name], id="page_title"),
|
||||
html.H2(children=[NAME], id="page_title"),
|
||||
dcc.Loading(
|
||||
overlay_style={"visibility": "visible", "filter": "blur(2px)"},
|
||||
id="loading-statistques",
|
||||
@@ -142,7 +142,7 @@ Alors, on fait comment ?
|
||||
dbc.Col(
|
||||
dcc.Dropdown(
|
||||
id="dashboard_year",
|
||||
options=options_years,
|
||||
options=OPTIONS_YEARS,
|
||||
placeholder="12 derniers mois",
|
||||
persistence=True,
|
||||
persistence_type="local",
|
||||
@@ -182,7 +182,7 @@ Alors, on fait comment ?
|
||||
searchable=True,
|
||||
multi=True,
|
||||
placeholder="Département",
|
||||
options=options_departements,
|
||||
options=OPTIONS_DEPARTEMENTS,
|
||||
persistence=True,
|
||||
persistence_type="local",
|
||||
),
|
||||
@@ -221,7 +221,7 @@ Alors, on fait comment ?
|
||||
searchable=True,
|
||||
multi=True,
|
||||
placeholder="Département",
|
||||
options=options_departements,
|
||||
options=OPTIONS_DEPARTEMENTS,
|
||||
persistence=True,
|
||||
persistence_type="local",
|
||||
),
|
||||
@@ -822,20 +822,20 @@ def add_organization_name_in_title(acheteur_id, titulaire_id):
|
||||
return match[nom_col].item(0) if match.height >= 1 else None
|
||||
|
||||
if acheteur_id and len(acheteur_id) == 14:
|
||||
if nom := lookup_nom(df_acheteurs, "acheteur_id", "acheteur_nom", acheteur_id):
|
||||
if nom := lookup_nom(DF_ACHETEURS, "acheteur_id", "acheteur_nom", acheteur_id):
|
||||
return [
|
||||
name,
|
||||
NAME,
|
||||
html.Small(nom, className="text-muted d-block fw-normal fs-5"),
|
||||
]
|
||||
elif titulaire_id and len(titulaire_id) == 14:
|
||||
if nom := lookup_nom(
|
||||
df_titulaires, "titulaire_id", "titulaire_nom", titulaire_id
|
||||
DF_TITULAIRES, "titulaire_id", "titulaire_nom", titulaire_id
|
||||
):
|
||||
return [
|
||||
name,
|
||||
NAME,
|
||||
html.Small(nom, className="text-muted d-block fw-normal fs-5"),
|
||||
]
|
||||
return name
|
||||
return NAME
|
||||
|
||||
|
||||
@callback(
|
||||
@@ -899,8 +899,8 @@ def populate_preview_table(
|
||||
)
|
||||
def update_hidden_columns_from_checkboxes(selected_columns):
|
||||
if selected_columns:
|
||||
selected_columns = [columns[i] for i in selected_columns]
|
||||
hidden_columns = [col for col in columns if col not in selected_columns]
|
||||
selected_columns = [COLUMNS[i] for i in selected_columns]
|
||||
hidden_columns = [col for col in COLUMNS if col not in selected_columns]
|
||||
return hidden_columns
|
||||
else:
|
||||
return []
|
||||
@@ -928,7 +928,7 @@ def update_checkboxes_from_hidden_columns(hidden_cols, current_checkboxes):
|
||||
hidden_cols = hidden_cols or get_default_hidden_columns("tableau")
|
||||
|
||||
# Show all columns that are NOT hidden
|
||||
visible_cols = [columns.index(col) for col in columns if col not in hidden_cols]
|
||||
visible_cols = [COLUMNS.index(col) for col in COLUMNS if col not in hidden_cols]
|
||||
return visible_cols
|
||||
|
||||
|
||||
|
||||
@@ -2,23 +2,23 @@ import dash_bootstrap_components as dbc
|
||||
from dash import Input, Output, State, callback, dcc, html, register_page
|
||||
|
||||
from src.figures import DataTable
|
||||
from src.utils import (
|
||||
df_acheteurs,
|
||||
df_titulaires,
|
||||
meta_content,
|
||||
from src.old_utils import (
|
||||
DF_ACHETEURS,
|
||||
DF_TITULAIRES,
|
||||
META_CONTENT,
|
||||
search_org,
|
||||
setup_table_columns,
|
||||
)
|
||||
|
||||
name = "Recherche"
|
||||
NAME = "Recherche"
|
||||
|
||||
register_page(
|
||||
__name__,
|
||||
path="/",
|
||||
title="Recherche de marchés publics | decp.info",
|
||||
name=name,
|
||||
name=NAME,
|
||||
description="Explorez et analysez les données des marchés publics français avec cet outil libre et gratuit. Pour une commande publique accessible à toutes et tous.",
|
||||
image_url=meta_content["image_url"],
|
||||
image_url=META_CONTENT["image_url"],
|
||||
order=0,
|
||||
)
|
||||
|
||||
@@ -97,9 +97,9 @@ def update_search_results(n_submit, n_clicks, query):
|
||||
|
||||
for org_type in ["acheteur", "titulaire"]:
|
||||
if org_type == "acheteur":
|
||||
dff = df_acheteurs
|
||||
dff = DF_ACHETEURS
|
||||
elif org_type == "titulaire":
|
||||
dff = df_titulaires
|
||||
dff = DF_TITULAIRES
|
||||
else:
|
||||
raise ValueError(f"{org_type} is not supported")
|
||||
|
||||
|
||||
+11
-11
@@ -21,13 +21,13 @@ from dash import (
|
||||
|
||||
from src.db import query_marches, schema
|
||||
from src.figures import DataTable, make_column_picker
|
||||
from src.utils import (
|
||||
columns,
|
||||
from src.old_utils import (
|
||||
COLUMNS,
|
||||
META_CONTENT,
|
||||
filter_table_data,
|
||||
get_default_hidden_columns,
|
||||
invert_columns,
|
||||
logger,
|
||||
meta_content,
|
||||
prepare_table_data,
|
||||
sort_table_data,
|
||||
)
|
||||
@@ -37,18 +37,18 @@ update_date = datetime.fromtimestamp(update_date_timestamp).strftime("%d/%m/%Y")
|
||||
update_date_iso = datetime.fromtimestamp(update_date_timestamp).isoformat()
|
||||
|
||||
|
||||
name = "Tableau"
|
||||
NAME = "Tableau"
|
||||
register_page(
|
||||
__name__,
|
||||
path="/tableau",
|
||||
title="Tableau des marchés publics | decp.info",
|
||||
name=name,
|
||||
name=NAME,
|
||||
description="Consultez, filtrez et exportez les données essentielles de la commande publique sous forme de tableau.",
|
||||
image_url=meta_content["image_url"],
|
||||
image_url=META_CONTENT["image_url"],
|
||||
order=1,
|
||||
)
|
||||
|
||||
datatable = html.Div(
|
||||
DATATABLE = html.Div(
|
||||
className="marches_table",
|
||||
children=DataTable(
|
||||
dtid="tableau_datatable",
|
||||
@@ -272,7 +272,7 @@ layout = [
|
||||
scrollable=True,
|
||||
size="xl",
|
||||
),
|
||||
datatable,
|
||||
DATATABLE,
|
||||
],
|
||||
),
|
||||
]
|
||||
@@ -480,8 +480,8 @@ def toggle_tableau_help(click_open, click_close, is_open):
|
||||
)
|
||||
def update_hidden_columns_from_checkboxes(selected_columns):
|
||||
if selected_columns:
|
||||
selected_columns = [columns[i] for i in selected_columns]
|
||||
hidden_columns = [col for col in columns if col not in selected_columns]
|
||||
selected_columns = [COLUMNS[i] for i in selected_columns]
|
||||
hidden_columns = [col for col in COLUMNS if col not in selected_columns]
|
||||
return hidden_columns
|
||||
else:
|
||||
return []
|
||||
@@ -509,7 +509,7 @@ def update_checkboxes_from_hidden_columns(hidden_cols, current_checkboxes):
|
||||
hidden_cols = hidden_cols or get_default_hidden_columns("tableau")
|
||||
|
||||
# Show all columns that are NOT hidden
|
||||
visible_cols = [columns.index(col) for col in columns if col not in hidden_cols]
|
||||
visible_cols = [COLUMNS.index(col) for col in COLUMNS if col not in hidden_cols]
|
||||
return visible_cols
|
||||
|
||||
|
||||
|
||||
+11
-11
@@ -23,23 +23,23 @@ from src.figures import (
|
||||
make_column_picker,
|
||||
point_on_map,
|
||||
)
|
||||
from src.utils import (
|
||||
columns,
|
||||
df_titulaires,
|
||||
from src.old_utils import (
|
||||
COLUMNS,
|
||||
DF_TITULAIRES,
|
||||
META_CONTENT,
|
||||
filter_table_data,
|
||||
format_number,
|
||||
get_annuaire_data,
|
||||
get_button_properties,
|
||||
get_default_hidden_columns,
|
||||
get_departement_region,
|
||||
meta_content,
|
||||
prepare_table_data,
|
||||
sort_table_data,
|
||||
)
|
||||
|
||||
|
||||
def get_title(titulaire_id: str = None) -> str:
|
||||
titulaire_nom = df_titulaires.filter(pl.col("titulaire_id") == titulaire_id).select(
|
||||
titulaire_nom = DF_TITULAIRES.filter(pl.col("titulaire_id") == titulaire_id).select(
|
||||
"titulaire_nom"
|
||||
)
|
||||
if titulaire_nom.height > 0:
|
||||
@@ -53,11 +53,11 @@ register_page(
|
||||
title=get_title,
|
||||
name="Titulaire",
|
||||
description="Consultez les marchés publics remportés par ce titulaire.",
|
||||
image_url=meta_content["image_url"],
|
||||
image_url=META_CONTENT["image_url"],
|
||||
order=5,
|
||||
)
|
||||
|
||||
datatable = html.Div(
|
||||
DATATABLE = html.Div(
|
||||
className="marches_table",
|
||||
children=DataTable(
|
||||
dtid="titulaire_datatable",
|
||||
@@ -239,7 +239,7 @@ layout = [
|
||||
scrollable=True,
|
||||
size="xl",
|
||||
),
|
||||
datatable,
|
||||
DATATABLE,
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -476,8 +476,8 @@ clientside_callback(
|
||||
)
|
||||
def update_hidden_columns_from_checkboxes(selected_columns):
|
||||
if selected_columns:
|
||||
selected_columns = [columns[i] for i in selected_columns]
|
||||
hidden_columns = [col for col in columns if col not in selected_columns]
|
||||
selected_columns = [COLUMNS[i] for i in selected_columns]
|
||||
hidden_columns = [col for col in COLUMNS if col not in selected_columns]
|
||||
return hidden_columns
|
||||
else:
|
||||
return []
|
||||
@@ -505,7 +505,7 @@ def update_checkboxes_from_hidden_columns(hidden_cols, current_checkboxes):
|
||||
hidden_cols = hidden_cols or get_default_hidden_columns("titulaire")
|
||||
|
||||
# Show all columns that are NOT hidden
|
||||
visible_cols = [columns.index(col) for col in columns if col not in hidden_cols]
|
||||
visible_cols = [COLUMNS.index(col) for col in COLUMNS if col not in hidden_cols]
|
||||
return visible_cols
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user