From 2c4f79edbbb4aa2c01b54e67fe21d173f396f2dc Mon Sep 17 00:00:00 2001 From: Tykayn Date: Tue, 16 Sep 2025 01:09:20 +0200 Subject: [PATCH] add plan in todo readme --- README.md | 3 + backend.py | 1 + extractors/osm_cal.py | 2 + oedb/resources/demo.py | 448 ++++++++++++++++++++++++++++++++++++++++- 4 files changed, 450 insertions(+), 4 deletions(-) create mode 100644 extractors/osm_cal.py diff --git a/README.md b/README.md index fc574be..c14aa61 100644 --- a/README.md +++ b/README.md @@ -155,6 +155,9 @@ page de démo listant les évènements selon leur type, les afficher sur une car créer une page de démo qui permet de modifier un évènement, faire un lien vers cette page quand on ouvre une popup d'évènement sur la page de /demo. et afficher une icone pour les marqueurs de carte selon le type d'évènement, définis en quelques uns et utilise les icones de bulma css. vérifier le fonctionnement des endpoints de recherche avec les queryparameters, les mettre dans la page de démo. +la page /demo/by-what a une erreur, Error: Expecting value: line 1 column 1 (char 0) +récupérer les évènements depuis osmcal dans esm_cal.py +dans les extracteurs, vérifier qu'il n'existe pas déjà des évènements avec les mês propriétés avant de les créer. ## License diff --git a/backend.py b/backend.py index 578f70f..b210f96 100644 --- a/backend.py +++ b/backend.py @@ -61,6 +61,7 @@ def create_app(): app.add_route('/demo/add', event_form) # Handle event submission form app.add_route('/demo/by-what', demo, suffix='by_what') # Handle events by type page app.add_route('/demo/map-by-what', demo, suffix='map_by_what') # Handle map by event type page + app.add_route('/demo/edit/{id}', demo, suffix='edit') # Handle event editing page logger.success("Application initialized successfully") return app diff --git a/extractors/osm_cal.py b/extractors/osm_cal.py new file mode 100644 index 0000000..3255ff5 --- /dev/null +++ b/extractors/osm_cal.py @@ -0,0 +1,2 @@ +# récupérer les évènements depuis osmcal.depuis +# https://osmcal.org/events.rss \ No newline at end of file diff --git a/oedb/resources/demo.py b/oedb/resources/demo.py index 24642f3..2c99a50 100644 --- a/oedb/resources/demo.py +++ b/oedb/resources/demo.py @@ -11,9 +11,403 @@ from oedb.utils.logging import logger class DemoResource: """ Resource for the demo endpoint. - Handles the /demo endpoint. + Handles the /demo endpoint and related demo pages. """ + def on_get_edit(self, req, resp, id=None): + """ + Handle GET requests to the /demo/edit endpoint. + Returns an HTML page with a form for editing an existing event. + + Args: + req: The request object. + resp: The response object. + id: The event ID to edit. + """ + logger.info(f"Processing GET request to /demo/edit for event ID: {id}") + + if id is None: + resp.status = falcon.HTTP_400 + resp.text = "Event ID is required" + return + + try: + # Set content type to HTML + resp.content_type = 'text/html' + + # Fetch the event data from the API + response = requests.get(f'http://localhost/event/{id}') + + if response.status_code != 200: + resp.status = falcon.HTTP_404 + resp.text = f"Event with ID {id} not found" + return + + event_data = response.json() + + # Create HTML response with form + html = f""" + + + + + + Edit Event - OpenEventDatabase + + + + + + +
+ + +

Edit Event

+ +
+ + +
+ + +
+ +
+
+ + +
+ +
+ + +
Category of the event (e.g., sport.match.football, culture.festival)
+
+
+ +
+
+ + +
Series or group the event belongs to (e.g., Euro 2024, Summer Festival 2023)
+
+ +
+ + +
Specific location name (e.g., Eiffel Tower, Wembley Stadium)
+
+
+ +
+
+ + +
+ +
+ + +
+
+ +
+ +
+
Click on the map to set the event location
+
+ + +
+ +
+
+ + + + + """ + + # Set the response body and status + resp.text = html.replace('{event_data}', json.dumps(event_data)) + resp.status = falcon.HTTP_200 + logger.success(f"Successfully processed GET request to /demo/edit for event ID: {id}") + except Exception as e: + logger.error(f"Error processing GET request to /demo/edit: {e}") + resp.status = falcon.HTTP_500 + resp.text = f"Error: {str(e)}" + def on_get(self, req, resp): """ Handle GET requests to the /demo endpoint. @@ -39,6 +433,8 @@ class DemoResource: OpenEventDatabase Demo + +