airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [2/2] airavata-django-portal git commit: Renamed ViewSet base classes, updated docs
Date Thu, 21 Sep 2017 13:05:19 GMT
Renamed ViewSet base classes, updated docs


Project: http://git-wip-us.apache.org/repos/asf/airavata-django-portal/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata-django-portal/commit/b82ebc11
Tree: http://git-wip-us.apache.org/repos/asf/airavata-django-portal/tree/b82ebc11
Diff: http://git-wip-us.apache.org/repos/asf/airavata-django-portal/diff/b82ebc11

Branch: refs/heads/master
Commit: b82ebc11d70d6dbb03dcd94840f5156c41695704
Parents: 802f556
Author: Marcus Christie <machrist@iu.edu>
Authored: Thu Sep 21 09:04:40 2017 -0400
Committer: Marcus Christie <machrist@iu.edu>
Committed: Thu Sep 21 09:04:40 2017 -0400

----------------------------------------------------------------------
 django_airavata/apps/api/views.py | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-django-portal/blob/b82ebc11/django_airavata/apps/api/views.py
----------------------------------------------------------------------
diff --git a/django_airavata/apps/api/views.py b/django_airavata/apps/api/views.py
index 416fa5a..38435db 100644
--- a/django_airavata/apps/api/views.py
+++ b/django_airavata/apps/api/views.py
@@ -59,26 +59,41 @@ class GenericAPIBackedViewSet(GenericViewSet):
     def authz_token(self):
         return self.request.authz_token
 
-class CreateUpdateRetrieveListViewSet(mixins.CreateModelMixin,
-                                      mixins.RetrieveModelMixin,
-                                      mixins.UpdateModelMixin,
-                                      mixins.DestroyModelMixin,
-                                      mixins.ListModelMixin,
-                                      GenericAPIBackedViewSet):
+
+class ReadOnlyAPIBackedViewSet(mixins.RetrieveModelMixin,
+                               mixins.ListModelMixin,
+                               GenericAPIBackedViewSet):
+    """
+    A viewset that provides default `retrieve()` and `list()` actions.
+
+    Subclasses must implement the following:
+    * get_list(self)
+    * get_instance(self, lookup_value)
+    """
+    pass
+
+
+class APIBackedViewSet(mixins.CreateModelMixin,
+                       mixins.RetrieveModelMixin,
+                       mixins.UpdateModelMixin,
+                       mixins.DestroyModelMixin,
+                       mixins.ListModelMixin,
+                       GenericAPIBackedViewSet):
     """
     A viewset that provides default `create()`, `retrieve()`, `update()`,
-    `partial_update()` and `list()` actions.
+    `partial_update()`, `destroy()` and `list()` actions.
 
     Subclasses must implement the following:
     * get_list(self)
     * get_instance(self, lookup_value)
     * perform_create(self, serializer) - should return instance with id populated
     * perform_update(self, serializer)
+    * perform_destroy(self, instance)
     """
     pass
 
 
-class ProjectViewSet(CreateUpdateRetrieveListViewSet):
+class ProjectViewSet(APIBackedViewSet):
 
     serializer_class = serializers.ProjectSerializer
     lookup_field = 'project_id'
@@ -105,6 +120,7 @@ class ProjectViewSet(CreateUpdateRetrieveListViewSet):
         serializer = serializers.ExperimentSerializer(experiments, many=True, context={'request':
request})
         return Response(serializer.data)
 
+# TODO: convert to ViewSet
 class ExperimentList(APIView):
     def get(self, request, format=None):
         gateway_id = settings.GATEWAY_ID


Mime
View raw message