new-dawn / new_dawn_server

Backend Repo for 布咕
0 stars 0 forks source link

[Filtering][1/n] Add age and height filter when retrieve profile #141

Open duckmoll opened 5 years ago

duckmoll commented 5 years ago

IOS client should only retrieve user profiles filtered by preference like height and age. Take a look at "Tastypie" framework, add height and age filtering for profile resource, and create corresponding tests.

duckmoll commented 5 years ago

Filtering is also used here in user actions: https://github.com/new-dawn/new_dawn_server/blob/3c34050c67e7a6ceca9d06b6c924bd00a18f7ab6/new_dawn_server/actions/api/resources.py#L38 with tests: https://github.com/new-dawn/new_dawn_server/blob/3c34050c67e7a6ceca9d06b6c924bd00a18f7ab6/new_dawn_server/actions/api/tests/test_message.py#L213

duckmoll commented 5 years ago

We use ProfileResource's endpoint for ios client to retrieve profiles: https://github.com/new-dawn/new_dawn_server/blob/3c34050c67e7a6ceca9d06b6c924bd00a18f7ab6/new_dawn_server/users/api/resources.py#L248

tangziyi001 commented 5 years ago

Here is a short doc on how Django tastypie framework specifies filtering fields in a certain resource and be able to understand GET request that looking for a specific resource.

https://django-tastypie.readthedocs.io/en/latest/resources.html#basic-filtering

For this task, you can simply add "height" and "age" as filtering fields in profile resource and test it with a GET request like /api/v1/profile/?height=XXX&age=XXX

duckmoll commented 5 years ago

Here is how you can register a new user in unit test: https://github.com/new-dawn/new_dawn_server/blob/191951b98ca61c7c37cc3f47f0f9749cd952b744/new_dawn_server/users/api/tests/test_users_api.py#L47 Include all user information in "data" parameter.