MLTSHP / mltshp

Source for the application that runs mltshp.com
https://mltshp.com/
Mozilla Public License 2.0
50 stars 21 forks source link

Add API endpoints for loading Shakes by ID/path #570

Closed spaceninja closed 4 years ago

spaceninja commented 4 years ago

This commit adds two new routes for new API endpoints that will allow loading the details of a shake either by ID or by path.

This solves the problem that currently API users can only access shake information as part of a user API response, not directly.

Fixes #569

spaceninja commented 4 years ago

I copied the examples in the routes file and api file, but 1) I don't know Python, so I don't know if I messed anything up, and 2) I don't know how to test this change.

@vosechu @bradchoate This API endpoint would be really helpful. Would either of you mind reviewing, and letting me know if I'm missing anything?

spaceninja commented 4 years ago

I just realized that this won't return a User object with the Shake, since the existing logic assumes the Shake will itself be embedded in a User object. It would be nice if this could handle that, but it's beyond my abilities. Even without the user object, this API endpoint would be useful to me, but it'd be awesome if someone who understands Python more than me could point me in the right direction for extending the Shake object with User data when it's part of this endpoint.

bradchoate commented 4 years ago

I just realized that this won't return a User object with the Shake, since the existing logic assumes the Shake will itself be embedded in a User object. It would be nice if this could handle that, but it's beyond my abilities. Even without the user object, this API endpoint would be useful to me, but it'd be awesome if someone who understands Python more than me could point me in the right direction for extending the Shake object with User data when it's part of this endpoint.

You're passing extended=True to the as_json() method, which should be including an owner property which is a user object. Is it not?