[PATCH v5 06/10] REST: Add Patches to the API

Finucane, Stephen stephen.finucane at intel.com
Thu Jun 2 23:23:15 AEST 2016

On 26 May 20:12, Andy Doan wrote:
> This exposes patches via the REST API.
> Security Constraints:
>  * Anyone (logged in or not) can read all objects.
>  * No one can create/delete objects.
>  * Project maintainers are allowed to update (ie "patch"
>    attributes)
> NOTE: Patch.save was overridden incorrectly and had to be
> fixed to work with DRF.
> Signed-off-by: Andy Doan <andy.doan at linaro.org>

One item. Again, fixable by me if you like.

> +    def to_representation(self, instance):
> +        data = super(PatchSerializer, self).to_representation(instance)
> +        headers = data.get('headers')
> +        if headers is not None:
> +            data['headers'] = email.parser.Parser().parsestr(headers, True)
> +            data['tags'] = [{'name': x.tag.name, 'count': x.count}
> +                            for x in instance.patchtag_set.all()]

This line needs to be unindented to ensure tags are listed on the
'patch-list' page (I think we should do this, IMO). If we don't want to
list them here, they should still be unindented and simply removed in
the PatchListSerializer code.

On another note, is there any advantage in displaying the tags per user,
rather than a cumulative count, like so:

        "Reviewed-by": [

This could be dumb/poor-performing suggestion, so it's just that :)


More information about the Patchwork mailing list