diff mbox

[v2,11/13] REST: Add maintainers to '/projects'

Message ID 1479574288-24171-12-git-send-email-stephen@that.guru
State Superseded
Headers show

Commit Message

Stephen Finucane Nov. 19, 2016, 4:51 p.m. UTC
This is in the UI. Expose it in the API.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Cc: Andy Doan <andy.doan@linaro.org>
---
 patchwork/api/project.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Daniel Axtens Nov. 21, 2016, 4:05 a.m. UTC | #1
Hi Stephen,

LGTM.

Reviewed-by: Daniel Axtens <dja@axtens.net>

Regards,
Daniel

> This is in the UI. Expose it in the API.
>
> Signed-off-by: Stephen Finucane <stephen@that.guru>
> Cc: Andy Doan <andy.doan@linaro.org>
> ---
>  patchwork/api/project.py | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/patchwork/api/project.py b/patchwork/api/project.py
> index dd6370d..388081a 100644
> --- a/patchwork/api/project.py
> +++ b/patchwork/api/project.py
> @@ -21,6 +21,7 @@ from rest_framework.generics import ListAPIView
>  from rest_framework.generics import RetrieveUpdateAPIView
>  from rest_framework.serializers import CharField
>  from rest_framework.serializers import HyperlinkedModelSerializer
> +from rest_framework.serializers import HyperlinkedRelatedField
>  
>  from patchwork.api import PatchworkPermission
>  from patchwork.models import Project
> @@ -31,11 +32,15 @@ class ProjectSerializer(HyperlinkedModelSerializer):
>      link_name = CharField(max_length=255, source='linkname')
>      list_id = CharField(max_length=255, source='listid')
>      list_email = CharField(max_length=255, source='listemail')
> +    maintainers = HyperlinkedRelatedField(
> +        many=True, read_only=True, view_name='api-user-detail',
> +        source='maintainer_project')
>  
>      class Meta:
>          model = Project
>          fields = ('id', 'url', 'name', 'link_name', 'list_id', 'list_email',
> -                  'web_url', 'scm_url', 'webscm_url')
> +                  'web_url', 'scm_url', 'webscm_url', 'maintainers')
> +        read_only_fields = ('maintainers',)
>          extra_kwargs = {
>              'url': {'view_name': 'api-project-detail'},
>          }
> -- 
> 2.7.4
>
> _______________________________________________
> Patchwork mailing list
> Patchwork@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/patchwork
Andy Doan Nov. 22, 2016, 6:19 p.m. UTC | #2
On 11/19/2016 10:51 AM, Stephen Finucane wrote:
> This is in the UI. Expose it in the API.
>
> Signed-off-by: Stephen Finucane <stephen@that.guru>
> Cc: Andy Doan <andy.doan@linaro.org>

Lets add a test for this one.
Stephen Finucane Nov. 24, 2016, 8:06 p.m. UTC | #3
On Tue, 2016-11-22 at 12:19 -0600, Andy Doan wrote:
> On 11/19/2016 10:51 AM, Stephen Finucane wrote:
> > 
> > This is in the UI. Expose it in the API.
> > 
> > Signed-off-by: Stephen Finucane <stephen@that.guru>
> > Cc: Andy Doan <andy.doan@linaro.org>
> 
> Lets add a test for this one.

Done and done.
diff mbox

Patch

diff --git a/patchwork/api/project.py b/patchwork/api/project.py
index dd6370d..388081a 100644
--- a/patchwork/api/project.py
+++ b/patchwork/api/project.py
@@ -21,6 +21,7 @@  from rest_framework.generics import ListAPIView
 from rest_framework.generics import RetrieveUpdateAPIView
 from rest_framework.serializers import CharField
 from rest_framework.serializers import HyperlinkedModelSerializer
+from rest_framework.serializers import HyperlinkedRelatedField
 
 from patchwork.api import PatchworkPermission
 from patchwork.models import Project
@@ -31,11 +32,15 @@  class ProjectSerializer(HyperlinkedModelSerializer):
     link_name = CharField(max_length=255, source='linkname')
     list_id = CharField(max_length=255, source='listid')
     list_email = CharField(max_length=255, source='listemail')
+    maintainers = HyperlinkedRelatedField(
+        many=True, read_only=True, view_name='api-user-detail',
+        source='maintainer_project')
 
     class Meta:
         model = Project
         fields = ('id', 'url', 'name', 'link_name', 'list_id', 'list_email',
-                  'web_url', 'scm_url', 'webscm_url')
+                  'web_url', 'scm_url', 'webscm_url', 'maintainers')
+        read_only_fields = ('maintainers',)
         extra_kwargs = {
             'url': {'view_name': 'api-project-detail'},
         }