From f7d0f87d0d942f31cb69d456c1b73198a2307c5d Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 2 May 2018 17:01:31 +0200 Subject: [PATCH] Api: minor changes --- mpwo_api/mpwo_api/activities/activities.py | 25 +++++++++++----------- mpwo_api/mpwo_api/activities/models.py | 2 +- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/mpwo_api/mpwo_api/activities/activities.py b/mpwo_api/mpwo_api/activities/activities.py index 1cab8313..da44cad0 100644 --- a/mpwo_api/mpwo_api/activities/activities.py +++ b/mpwo_api/mpwo_api/activities/activities.py @@ -40,21 +40,18 @@ def get_activity(auth_user_id, activity_id): if activity: activities_list.append(activity.serialize()) - response_object = { - 'status': 'success', - 'data': { - 'activities': activities_list - } - } + status = 'success' code = 200 else: - response_object = { - 'status': 'not found', - 'data': { - 'activities': activities_list - } - } + status = 'not found' code = 404 + + response_object = { + 'status': status, + 'data': { + 'activities': activities_list + } + } return jsonify(response_object), code @@ -119,7 +116,9 @@ def post_activity(auth_user_id): response_object = { 'status': 'created', - 'message': 'Activity added.' + 'data': { + 'activities': [new_activity.serialize()] + } } return jsonify(response_object), 201 diff --git a/mpwo_api/mpwo_api/activities/models.py b/mpwo_api/mpwo_api/activities/models.py index f7713b0d..247d359c 100644 --- a/mpwo_api/mpwo_api/activities/models.py +++ b/mpwo_api/mpwo_api/activities/models.py @@ -50,7 +50,7 @@ class Activity(db.Model): ave_speed = db.Column(db.Numeric(5, 2), nullable=True) def __str__(self): - return str(self.sport_id) + \ + return str(self.sports.label) + \ " - " + self.activity_date.strftime('%Y-%m-%d') def __init__(self, user_id, sport_id, activity_date, duration):