[Patchew-devel] [PATCH] rest: include URI links for all nested views

Paolo Bonzini posted 1 patch 6 years, 3 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/patchew-ci tags/patchew/20180409122133.8374-1-pbonzini@redhat.com
api/rest.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
[Patchew-devel] [PATCH] rest: include URI links for all nested views
Posted by Paolo Bonzini 6 years, 3 months ago
A REST application should in theory not need to build URIs itself; everything
should be reachable from the top page.  We are pretty close to that, so do it
right.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 api/rest.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/api/rest.py b/api/rest.py
index 3a49e72..381b569 100644
--- a/api/rest.py
+++ b/api/rest.py
@@ -95,10 +95,15 @@ class ProjectSerializer(serializers.HyperlinkedModelSerializer):
     class Meta:
         model = Project
         fields = ('resource_uri', 'name', 'mailing_list', 'prefix_tags', 'url', 'git', \
-                  'description', 'display_order', 'logo', 'parent_project', 'results')
+                  'description', 'display_order', 'logo', 'parent_project', 'messages',
+                  'results', 'series')
 
+    messages = HyperlinkedIdentityField(view_name='messages-list', lookup_field='pk',
+                                        lookup_url_kwarg='projects_pk')
     results = HyperlinkedIdentityField(view_name='results-list', lookup_field='pk',
                                        lookup_url_kwarg='projects_pk')
+    series = HyperlinkedIdentityField(view_name='series-list', lookup_field='pk',
+                                       lookup_url_kwarg='projects_pk')
 
 class ProjectsViewSet(viewsets.ModelViewSet):
     queryset = Project.objects.all().order_by('id')
-- 
2.16.2

_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel