diff --git a/routes/eventRoutes.py b/routes/eventRoutes.py index 80c9e98..cfc99eb 100644 --- a/routes/eventRoutes.py +++ b/routes/eventRoutes.py @@ -54,7 +54,7 @@ def update_event(event_id): if updated_event: return jsonify(updated_event.to_dict()), 200 else: - return jsonify({'error': 'Failed to update event'}), 400 + return jsonify({'error': 'Event not found'}), 404 except Exception as e: return jsonify({'error': str(e)}), 500 @@ -67,6 +67,6 @@ def delete_event(event_id): if deleted_event: return jsonify(deleted_event.to_dict()), 200 else: - return jsonify({'error': 'Failed to delete event'}), 400 + return jsonify({'error': 'Event not found'}), 404 except Exception as e: return jsonify({'error': str(e)}), 500 \ No newline at end of file diff --git a/services/EventService.py b/services/EventService.py index a197431..42e9720 100644 --- a/services/EventService.py +++ b/services/EventService.py @@ -4,8 +4,6 @@ from datetime import datetime class EventService: @staticmethod def create_event(data): - print("#########") - print(data) new_event = Event( title=data['title'], description=data.get('description', ''), @@ -36,6 +34,8 @@ class EventService: @staticmethod def update_event(event_id, data): event = Event.query.get(event_id) + if not event: + return None event.title = data['title'] event.description = data.get('description', '') event.location = data.get('location', '')