Compare commits

...

17 Commits

Author SHA1 Message Date
Colin Maudry 2f3ce6a467 Amélioration du message d'annonce 2025-11-11 09:04:11 +01:00
Colin Maudry efd9bd4238 Merge branch 'hotfix/2.1.7' 2025-11-11 08:39:58 +01:00
Colin Maudry 39844071ad Changelog 2.1.7 2025-11-11 08:39:41 +01:00
Colin Maudry 5c64177c6a Remplacement du formulaire de contact par email 2025-11-11 08:37:47 +01:00
Colin Maudry ee91e7a91f Merge branch 'hotfix/2.1.6' 2025-10-15 19:44:09 +02:00
Colin Maudry 392f862baa Changelog 2.1.6 2025-10-15 19:44:02 +02:00
Colin Maudry 199476ec30 Stabilisation affichage fiche marché #40 2025-10-15 19:42:53 +02:00
Colin Maudry c98a36f759 Fix fiche marche 2025-10-14 12:54:47 +02:00
Colin Maudry 65e0f4c5f0 Gestion des montants inexistants 2025-10-10 18:25:08 +02:00
Colin Maudry bc7652f336 Merge branch 'main' into dev 2025-10-10 17:48:47 +02:00
Colin Maudry 188383a882 Changelog 2.1.5 2025-10-10 17:47:18 +02:00
Colin Maudry 7f3a0bcb21 Renommage de la Github action d'auto release 2025-10-10 17:45:15 +02:00
Colin Maudry 3270abb7f6 Refactor du filtre pour être plus résilient (et fonctionner sur les montants) 2025-10-10 17:44:51 +02:00
Colin Maudry 2eb984a95f Ne plus afficher de nulls dans les tableaux de données (tableau, titulaire, acheteur) 2025-10-10 17:44:16 +02:00
Colin Maudry 776126a481 Merge tag 'v2.1.4' into dev
- possibilité de filtrer sur le champ "Source"
- création automatique d'une release Github quand je push un tag
2025-10-08 09:34:30 +02:00
Colin Maudry 816d0de324 Merge tag 'v2.1.1' into dev
- ajout d'une section dans À propos sur la qualité et l'exhaustivité des données ([#43](https://github.com/ColinMaudry/decp.info/issues/43))
- ajout du nombre de marchés en plus du nombre de lignes dans la vue Tableau
2025-10-01 13:22:42 +02:00
Colin Maudry 90e9bc3c8c Merge tag 'v2.1.0' into dev
- Ajout des vues [acheteur](https://decp.info/acheteurs/24350013900189) ([#28](https://github.com/ColinMaudry/decp.info/issues/28)), [titulaire](https://decp.info/titulaires/51903758414786)
([#35](https://github.com/ColinMaudry/decp.info/issues/35)) et [marché](https://decp.info/marches/532239472000482025S00004) ([#40](https://github.com/ColinMaudry/decp.info/issues/40)) 🔎
 - Ajout des balises HTML meta Open Graph et Twitter ([#39](https://github.com/ColinMaudry/decp.info/issues/39)) pour de beaux aperçus de liens 🖼️
- Formulaire de contact ([#48](https://github.com/ColinMaudry/decp.info/issues/48)) 📨
- Nom de colonnes plus_agréables ([#33](https://github.com/ColinMaudry/decp.info/issues/33)) 💅
- Définition des colonnes quand vous passez votre souris sur les en-têtes ([#33](https://github.com/ColinMaudry/decp.info/issues/33)) 📖#
- Affichage du numéro de version près du logo et lien vers ici 🤓
- Variables globales uniquement en lecture (😁)
2025-09-30 17:16:45 +02:00
11 changed files with 196 additions and 158 deletions
+2 -2
View File
@@ -4,11 +4,11 @@ on:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
name: Create Release
name: Auto-release d'un tag
jobs:
build:
name: Auto-release d'un tag
name: auto-release
runs-on: ubuntu-latest
steps:
- name: Checkout code
+14 -1
View File
@@ -1,6 +1,6 @@
# decp.info
> v2.1.4
> v2.1.7
Outil d'exploration et de téléchargement des données essentielles de la commande publique.
@@ -38,6 +38,19 @@ Ne pas oublier de mettre à jour les fichier .env.
## Notes de version
##### 2.1.7 (11 novembre 2025)
- Remplacement du formulaire de contact par une adresse email
##### 2.1.6 (15 octobre 2025)
- Stabilisation de la vue marché
##### 2.1.5 (10 octobre 2025)
- réparation des filtres (notamment < > sur les montants)
- remplacement des valeurs "null" dans les tableaux par des cellules vides
##### 2.1.4 (8 octobre 2025)
- possibilité de filtrer sur le champ "Source"
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "decp.info"
description = "Interface d'exploration et d'analyse des marchés publics français."
version = "2.1.4"
version = "2.1.7"
requires-python = ">= 3.10"
authors = [
{ name = "Colin Maudry", email = "colin+decp@maudry.com" }
+6
View File
@@ -90,6 +90,12 @@ app.layout = html.Div(
],
className="logo",
),
html.Div(
id="announcements",
children=dcc.Markdown(
"️ Le formulaire de contact, défectueux, a été remplacé par [une adresse email](/contact)."
),
),
html.Div(
[
dcc.Link(
+7
View File
@@ -142,6 +142,13 @@ td[data-dash-column="objet"] {
margin: 0 0 20px 20px;
}
/* Annonces */
#announcements {
margin-top: 25px;
max-width: 30%;
font-size: 90%;
}
/* Menu de navigation */
.navbar {
+2 -1
View File
@@ -175,7 +175,6 @@ def get_acheteur_marches_data(url, acheteur_year: str) -> list[dict]:
acheteur_siret = url.split("/")[-1]
lff = df.lazy()
lff = lff.filter(pl.col("acheteur_id") == acheteur_siret)
lff = lff.fill_null("")
lff = lff.select(
"id",
"uid",
@@ -204,6 +203,8 @@ def get_acheteur_marches_data(url, acheteur_year: str) -> list[dict]:
)
def get_last_marches_table(data) -> html.Div:
dff = pl.DataFrame(data)
dff = dff.cast(pl.String)
dff = dff.fill_null("")
dff = format_montant(dff)
columns, tooltip = setup_table_columns(
dff,
+117 -120
View File
@@ -1,11 +1,7 @@
import os
import re
import smtplib
import time
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from dash import Input, Output, State, callback, dcc, html, register_page
from dash import dcc, html, register_page
from flask import request
from src.utils import meta_content
@@ -25,51 +21,52 @@ layout = html.Div(
className="container",
children=[
html.H2("Contact", id="contact"),
html.P(
"Votre message arrivera directement dans ma boîte mail, et je reviendrai vers vous rapidement."
),
html.Div(
[
html.Label("Votre nom"),
dcc.Input(
id="input-name",
type="text",
style={"width": "100%", "padding": "8px", "margin": "8px 0"},
),
html.Label("Votre adresse email"),
dcc.Input(
id="input-email",
type="email",
style={"width": "100%", "padding": "8px", "margin": "8px 0"},
),
html.Label("Message"),
dcc.Textarea(
id="input-message",
style={
"width": "100%",
"height": 200,
"padding": "8px",
"margin": "8px 0",
},
),
html.Button(
"Envoyer ",
id="submit-button",
n_clicks=0,
style={"marginTop": "10px"},
),
html.Div(
id="output-message", style={"marginTop": "10px", "color": "green"}
),
],
style={
"maxWidth": "600px",
"margin": "auto",
"padding": "20px",
"lineHeight": "20px",
},
),
# html.P(
# "Votre message arrivera directement dans ma boîte mail, et je reviendrai vers vous rapidement."
# ),
# html.Div(
# [
# html.Label("Votre nom"),
# dcc.Input(
# id="input-name",
# type="text",
# style={"width": "100%", "padding": "8px", "margin": "8px 0"},
# ),
# html.Label("Votre adresse email"),
# dcc.Input(
# id="input-email",
# type="email",
# style={"width": "100%", "padding": "8px", "margin": "8px 0"},
# ),
# html.Label("Message"),
# dcc.Textarea(
# id="input-message",
# style={
# "width": "100%",
# "height": 200,
# "padding": "8px",
# "margin": "8px 0",
# },
# ),
# html.Button(
# "Envoyer ",
# id="submit-button",
# n_clicks=0,
# style={"marginTop": "10px"},
# ),
# html.Div(
# id="output-message", style={"marginTop": "10px", "color": "green"}
# ),
# ],
# style={
# "maxWidth": "600px",
# "margin": "auto",
# "padding": "20px",
# "lineHeight": "20px",
# },
# ),
dcc.Markdown("""
- Email : [colin+decp@maudry.com](mailto:colin+decp@maudry.com)
- Bluesky : [@col1m.bsky.social](https://bsky.app/profile/col1m.bsky.social)
- Mastodon : [col1m@mamot.fr](https://mamot.fr/@col1m)
- LinkedIn : [colinmaudry](https://www.linkedin.com/in/colinmaudry/)
@@ -97,74 +94,74 @@ def sanitize_email(email):
return re.match(r"[^@]+@[^@]+\.[^@]+", email)
@callback(
Output("output-message", "children"),
Input("submit-button", "n_clicks"),
State("input-name", "value"),
State("input-email", "value"),
State("input-message", "value"),
prevent_initial_call=True,
)
def send_email(n_clicks, form_name, form_email, form_message):
if not all([form_name, form_email, form_message]):
return html.Div(
"Veuillez s'il vous plaît remplir tous les champs.", style={"color": "red"}
)
client_ip = request.remote_addr
if is_rate_limited():
wait_time = int(RATE_LIMIT_WINDOW - (time.time() - rate_limit_store[client_ip]))
return html.Div(
f"⏳ J'ai mis en place une protection contre le spam, et vous m'avez écrit il y a moins de 5 minutes. "
f"Veuillez s'il vous plaît attendre {wait_time} secondes avant de renvoyer un message.",
style={"color": "black"},
)
try:
# Configuration du serveur SMTP
smtp_server = os.getenv("SENDER_SERVER_DOMAIN")
smtp_port = 587
login_email = os.getenv("LOGIN_EMAIL")
from_email = os.getenv("FROM_EMAIL")
to_email = os.getenv("TO_EMAIL", from_email)
login_password = os.getenv("LOGIN_PASSWORD")
print(
smtp_server,
smtp_port,
login_email,
from_email,
to_email,
login_password,
sep="\n",
)
# Création de l'email
email = MIMEMultipart()
email["From"] = from_email
email["To"] = to_email
email["Subject"] = f"[decp.info] Message de {form_name}"
body = f"""
Nom : {form_name}
Email : {form_email}
Message :
{form_message}
"""
email.attach(MIMEText(body, "plain"))
# Send email
server = smtplib.SMTP(smtp_server, smtp_port)
server.starttls()
server.login(login_email, login_password)
server.sendmail(from_email, to_email, email.as_string())
server.quit()
return html.Div("✅ Envoi réussi", style={"color": "green"})
except Exception as e:
print(e)
return html.Div(
f"❌ Échec de l'envoi du message : {str(e)}", style={"color": "red"}
)
# @callback(
# Output("output-message", "children"),
# Input("submit-button", "n_clicks"),
# State("input-name", "value"),
# State("input-email", "value"),
# State("input-message", "value"),
# prevent_initial_call=True,
# )
# def send_email(n_clicks, form_name, form_email, form_message):
# if not all([form_name, form_email, form_message]):
# return html.Div(
# "Veuillez s'il vous plaît remplir tous les champs.", style={"color": "red"}
# )
#
# client_ip = request.remote_addr
# if is_rate_limited():
# wait_time = int(RATE_LIMIT_WINDOW - (time.time() - rate_limit_store[client_ip]))
# return html.Div(
# f"⏳ J'ai mis en place une protection contre le spam, et vous m'avez écrit il y a moins de 5 minutes. "
# f"Veuillez s'il vous plaît attendre {wait_time} secondes avant de renvoyer un message.",
# style={"color": "black"},
# )
#
# try:
# # Configuration du serveur SMTP
# smtp_server = os.getenv("SENDER_SERVER_DOMAIN")
# smtp_port = 587
# login_email = os.getenv("LOGIN_EMAIL")
# from_email = os.getenv("FROM_EMAIL")
# to_email = os.getenv("TO_EMAIL", from_email)
# login_password = os.getenv("LOGIN_PASSWORD")
#
# print(
# smtp_server,
# smtp_port,
# login_email,
# from_email,
# to_email,
# login_password,
# sep="\n",
# )
#
# # Création de l'email
# email = MIMEMultipart()
# email["From"] = from_email
# email["To"] = to_email
# email["Subject"] = f"[decp.info] Message de {form_name}"
#
# body = f"""
# Nom : {form_name}
# Email : {form_email}
#
# Message :
# {form_message}
# """
# email.attach(MIMEText(body, "plain"))
#
# # Send email
# server = smtplib.SMTP(smtp_server, smtp_port)
# server.starttls()
# server.login(login_email, login_password)
# server.sendmail(from_email, to_email, email.as_string())
# server.quit()
#
# return html.Div("✅ Envoi réussi", style={"color": "green"})
#
# except Exception as e:
# print(e)
# return html.Div(
# f"❌ Échec de l'envoi du message : {str(e)}", style={"color": "red"}
# )
+2 -8
View File
@@ -66,6 +66,7 @@ def get_marche_data(url) -> tuple[dict, list]:
marche_uid = url.split("/")[-1]
# Récupération des données du marché à partir du df global
lff = df.lazy()
lff = lff.filter(pl.col("uid") == pl.lit(marche_uid))
@@ -73,13 +74,9 @@ def get_marche_data(url) -> tuple[dict, list]:
dff_titulaires = lff.select(cs.starts_with("titulaire")).collect(engine="streaming")
# Données du marché
dff_marche = (
lff.select(~cs.starts_with("titulaires")).unique().collect(engine="streaming")
)
dff_marche = lff.unique("uid").collect(engine="streaming")
dff_marche = format_montant(dff_marche)
assert dff_marche.height == 1
return dff_marche.to_dicts()[0], dff_titulaires.to_dicts()
@@ -93,7 +90,6 @@ def get_marche_data(url) -> tuple[dict, list]:
def update_marche_info(marche, titulaires):
def make_parameter(col):
column_object = data_schema.get(col)
print(column_object)
column_name = column_object.get("title") if column_object else col
if marche[col]:
@@ -110,8 +106,6 @@ def update_marche_info(marche, titulaires):
# Dates
elif col in ["dateNotification", "datePublicationDonnees"]:
print(marche[col])
value = datetime.fromisoformat(marche[col]).strftime("%d/%m/%Y")
# Listes
+6 -3
View File
@@ -182,9 +182,6 @@ def update_table(page_current, page_size, filter_query, sort_by, data_timestamp)
if len(sort_by) > 0:
lff = sort_table_data(lff, sort_by)
# Remplace les strings null par "", mais pas les numeric null
lff = lff.fill_null("")
# Matérialisation des filtres
dff: pl.DataFrame = lff.collect()
@@ -196,6 +193,12 @@ def update_table(page_current, page_size, filter_query, sort_by, data_timestamp)
# end_row = (page_current + 1) * page_size
dff = dff.slice(start_row, page_size)
# Tout devient string
dff = dff.cast(pl.String)
# Remplace les strings null par "", mais pas les numeric null
dff = dff.fill_null("")
# Ajout des liens vers l'annuaire des entreprises
dff = add_links(dff)
+2 -1
View File
@@ -180,7 +180,6 @@ def get_titulaire_marches_data(url, titulaire_year: str) -> list[dict]:
(pl.col("titulaire_id") == titulaire_siret)
& (pl.col("titulaire_typeIdentifiant") == "SIRET")
)
lff = lff.fill_null("")
lff = lff.select(
"id",
"uid",
@@ -218,6 +217,8 @@ def get_last_marches_table(data) -> html.Div:
]
dff = pl.DataFrame(data)
dff = dff.cast(pl.String)
dff = dff.fill_null("")
dff = format_montant(dff)
columns, tooltip = setup_table_columns(
dff, hideable=False, exclude=["acheteur_id", "id"]
+37 -21
View File
@@ -126,7 +126,8 @@ def format_number(number) -> str:
def format_montant(dff: pl.DataFrame) -> pl.DataFrame:
def format_function(expr, scale=None):
# https://stackoverflow.com/a/78636786
expr = expr.cast(pl.String).str.splitn(".", 2)
expr = expr.cast(pl.String)
expr = expr.str.splitn(".", 2)
num = expr.struct[0]
frac = expr.struct[1]
@@ -145,7 +146,13 @@ def format_montant(dff: pl.DataFrame) -> pl.DataFrame:
.otherwise(pl.lit(""))
)
return num + frac + pl.lit("")
montant: pl.Expr = (
pl.when((num + frac) == pl.lit(""))
.then(pl.lit(""))
.otherwise(num + frac + pl.lit(""))
)
return montant
dff = dff.with_columns(pl.col("montant").pipe(format_function).alias("montant"))
return dff
@@ -211,21 +218,30 @@ def filter_table_data(lff: pl.LazyFrame, filter_query: str) -> pl.LazyFrame:
filtering_expressions = filter_query.split(" && ")
for filter_part in filtering_expressions:
col_name, operator, filter_value = split_filter_part(filter_part)
col_type = str(schema[col_name])
if debug:
print("filter_value:", filter_value)
print("filter_value_type:", type(filter_value))
print("operator:", operator)
print("col_type:", col_type)
if col_type == "Date":
# Convertir la colonne en chaînes de caractères
lff = dates_to_strings(lff, col_name)
lff = lff.filter(pl.col(col_name).is_not_null())
if operator in ("<", "<=", ">", ">="):
lff = lff.filter(
pl.col(col_name).is_not_null() & (pl.col(col_name) != pl.lit(""))
)
if col_type == "Date":
# Convertir la colonne date en chaînes de caractères
lff = dates_to_strings(lff, col_name)
col_type = "String"
if col_type == "String":
lff = lff.filter(pl.col(col_name) != pl.lit(""))
elif col_type.startswith("Int") or col_type.startswith("Float"):
try:
filter_value = int(filter_value)
except ValueError:
logger.error(f"Invalid numeric filter value: {filter_value}")
continue
if operator in ("contains", "<", "<=", ">", ">="):
if operator == "<":
lff = lff.filter(pl.col(col_name) < filter_value)
elif operator == ">":
@@ -234,17 +250,17 @@ def filter_table_data(lff: pl.LazyFrame, filter_query: str) -> pl.LazyFrame:
lff = lff.filter(pl.col(col_name) >= filter_value)
elif operator == "<=":
lff = lff.filter(pl.col(col_name) <= filter_value)
elif col_type.startswith("Int") or col_type.startswith("Float"):
try:
filter_value = int(filter_value)
except ValueError:
logger.error(f"Invalid numeric filter value: {filter_value}")
continue
lff = lff.filter(pl.col(col_name) == filter_value)
elif operator == "contains" and col_type in ["String", "Date"]:
lff = lff.filter(pl.col(col_name).str.contains("(?i)" + filter_value))
elif operator == "contains":
if col_type in ["String", "Date"]:
lff = lff.filter(
pl.col(col_name).str.contains("(?i)" + filter_value)
)
elif col_type.startswith("Int") or col_type.startswith("Float"):
lff = lff.filter(pl.col(col_name) == filter_value)
else:
logger.error(f"Invalid column type: {col_type}")
else:
logger.error(f"Invalid operator: {operator}")
# elif operator == 'datestartswith':
# lff = lff.filter(pl.col(col_name).str.startswith(filter_value)")