Api: minor changes

This commit is contained in:
Sam 2018-05-02 17:01:31 +02:00
parent 561dc5b7a0
commit f7d0f87d0d
2 changed files with 13 additions and 14 deletions

View File

@ -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:
status = 'not found'
code = 404
response_object = {
'status': 'not found',
'status': status,
'data': {
'activities': activities_list
}
}
code = 404
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

View File

@ -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):