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 <[email protected]>

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": [
            "http://localhost:8000/api/1.0/people/28/";
        ]
    }

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

Stephen
_______________________________________________
Patchwork mailing list
[email protected]
https://lists.ozlabs.org/listinfo/patchwork

Reply via email to