[PATCHv2 04/10] REST: Add Persons to the API

Finucane, Stephen stephen.finucane at intel.com
Tue May 17 22:31:28 AEST 2016


On 10 May 17:39, Andy Doan wrote:
> This exports person objects via the REST API.
> 
> Security Constraints:
>  * The API is read-only to authenticated users
> 
> Signed-off-by: Andy Doan <andy.doan at linaro.org>

Still unsure about including 'person.user.id'. See comment below.

Stephen

> ---
>  patchwork/rest_serializers.py    |  7 ++++++-
>  patchwork/tests/test_rest_api.py | 41 ++++++++++++++++++++++++++++++++++++++++
>  patchwork/views/rest_api.py      | 26 ++++++++++++++++++++-----
>  3 files changed, 68 insertions(+), 6 deletions(-)
> 
> diff --git a/patchwork/rest_serializers.py b/patchwork/rest_serializers.py
> index b399d79..60633b4 100644
> --- a/patchwork/rest_serializers.py
> +++ b/patchwork/rest_serializers.py
> @@ -17,11 +17,16 @@
>  # along with Patchwork; if not, write to the Free Software
>  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
>  
> -from patchwork.models import Project
> +from patchwork.models import Person, Project
>  
>  from rest_framework.serializers import ModelSerializer
>  
>  
> +class PersonSerializer(ModelSerializer):
> +    class Meta:
> +        model = Person
> +

I think if we're not planning to expose a 'users' endpoint, we could
definitely drop the 'user' field. If possible though, we could include
the 'user.name' field, rather than the 'user.id', as this would be
something people likely care about. Don't know how easy this is to do,
but I imagine it would require use of the prefetch option once again.


More information about the Patchwork mailing list