Api: minor changes
This commit is contained in:
parent
561dc5b7a0
commit
f7d0f87d0d
@ -40,21 +40,18 @@ def get_activity(auth_user_id, activity_id):
|
|||||||
|
|
||||||
if activity:
|
if activity:
|
||||||
activities_list.append(activity.serialize())
|
activities_list.append(activity.serialize())
|
||||||
response_object = {
|
status = 'success'
|
||||||
'status': 'success',
|
|
||||||
'data': {
|
|
||||||
'activities': activities_list
|
|
||||||
}
|
|
||||||
}
|
|
||||||
code = 200
|
code = 200
|
||||||
else:
|
else:
|
||||||
|
status = 'not found'
|
||||||
|
code = 404
|
||||||
|
|
||||||
response_object = {
|
response_object = {
|
||||||
'status': 'not found',
|
'status': status,
|
||||||
'data': {
|
'data': {
|
||||||
'activities': activities_list
|
'activities': activities_list
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
code = 404
|
|
||||||
return jsonify(response_object), code
|
return jsonify(response_object), code
|
||||||
|
|
||||||
|
|
||||||
@ -119,7 +116,9 @@ def post_activity(auth_user_id):
|
|||||||
|
|
||||||
response_object = {
|
response_object = {
|
||||||
'status': 'created',
|
'status': 'created',
|
||||||
'message': 'Activity added.'
|
'data': {
|
||||||
|
'activities': [new_activity.serialize()]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return jsonify(response_object), 201
|
return jsonify(response_object), 201
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ class Activity(db.Model):
|
|||||||
ave_speed = db.Column(db.Numeric(5, 2), nullable=True)
|
ave_speed = db.Column(db.Numeric(5, 2), nullable=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.sport_id) + \
|
return str(self.sports.label) + \
|
||||||
" - " + self.activity_date.strftime('%Y-%m-%d')
|
" - " + self.activity_date.strftime('%Y-%m-%d')
|
||||||
|
|
||||||
def __init__(self, user_id, sport_id, activity_date, duration):
|
def __init__(self, user_id, sport_id, activity_date, duration):
|
||||||
|
Loading…
Reference in New Issue
Block a user