diff --git a/README.md b/README.md index 1d26aa4..53a30f0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # decp.info -> v2.1.6 +> v2.1.7 Outil d'exploration et de téléchargement des données essentielles de la commande publique. @@ -38,6 +38,10 @@ 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é diff --git a/pyproject.toml b/pyproject.toml index 0030ed6..5f29774 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "decp.info" description = "Interface d'exploration et d'analyse des marchés publics français." -version = "2.1.6" +version = "2.1.7" requires-python = ">= 3.10" authors = [ { name = "Colin Maudry", email = "colin+decp@maudry.com" } diff --git a/src/app.py b/src/app.py index 71fdb43..cc96a99 100644 --- a/src/app.py +++ b/src/app.py @@ -90,6 +90,12 @@ app.layout = html.Div( ], className="logo", ), + html.Div( + id="announcements", + children=html.P( + "ℹ️ Le formulaire de contact a été remplacé par une adresse email" + ), + ), html.Div( [ dcc.Link( diff --git a/src/assets/style.css b/src/assets/style.css index bf70592..3744bf7 100644 --- a/src/assets/style.css +++ b/src/assets/style.css @@ -142,6 +142,11 @@ td[data-dash-column="objet"] { margin: 0 0 20px 20px; } +/* Annonces */ +#announcements { + margin-top: 25px; +} + /* Menu de navigation */ .navbar { diff --git a/src/pages/contact.py b/src/pages/contact.py index a6f4051..b098a22 100644 --- a/src/pages/contact.py +++ b/src/pages/contact.py @@ -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"} +# )