You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2017/09/21 13:05:19 UTC
[2/2] airavata-django-portal git commit: Renamed ViewSet base classes,
updated docs
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 <ma...@iu.edu>
Authored: Thu Sep 21 09:04:40 2017 -0400
Committer: Marcus Christie <ma...@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