naming typo fix

This commit is contained in:
Kfir Dayan 2024-01-07 16:32:08 +02:00
parent 744fccfc54
commit 5ed71b8f91
2 changed files with 4 additions and 4 deletions

View file

@ -54,7 +54,7 @@ def update_event(event_id):
if updated_event: if updated_event:
return jsonify(updated_event.to_dict()), 200 return jsonify(updated_event.to_dict()), 200
else: else:
return jsonify({'error': 'Failed to update event'}), 400 return jsonify({'error': 'Event not found'}), 404
except Exception as e: except Exception as e:
return jsonify({'error': str(e)}), 500 return jsonify({'error': str(e)}), 500
@ -67,6 +67,6 @@ def delete_event(event_id):
if deleted_event: if deleted_event:
return jsonify(deleted_event.to_dict()), 200 return jsonify(deleted_event.to_dict()), 200
else: else:
return jsonify({'error': 'Failed to delete event'}), 400 return jsonify({'error': 'Event not found'}), 404
except Exception as e: except Exception as e:
return jsonify({'error': str(e)}), 500 return jsonify({'error': str(e)}), 500

View file

@ -4,8 +4,6 @@ from datetime import datetime
class EventService: class EventService:
@staticmethod @staticmethod
def create_event(data): def create_event(data):
print("#########")
print(data)
new_event = Event( new_event = Event(
title=data['title'], title=data['title'],
description=data.get('description', ''), description=data.get('description', ''),
@ -36,6 +34,8 @@ class EventService:
@staticmethod @staticmethod
def update_event(event_id, data): def update_event(event_id, data):
event = Event.query.get(event_id) event = Event.query.get(event_id)
if not event:
return None
event.title = data['title'] event.title = data['title']
event.description = data.get('description', '') event.description = data.get('description', '')
event.location = data.get('location', '') event.location = data.get('location', '')