This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git
The following commit(s) were added to refs/heads/master by this push:
new 4b6f174 Allow periods in REST API lookup values
4b6f174 is described below
commit 4b6f174f15b2f6857fd89dffa22ec8ef8e1f8552
Author: Marcus Christie <machrist@iu.edu>
AuthorDate: Thu Jan 24 16:06:07 2019 -0500
Allow periods in REST API lookup values
Airavata ids (e.g., application module id) may contain periods. The
default DRF lookup_value_regex, `[^/.]+`, doesn't allow periods in the
lookup value. This change globally configures a better default
lookup_value_regex for REST API viewsets.
---
django_airavata/apps/api/view_utils.py | 4 ++++
django_airavata/apps/api/views.py | 7 -------
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/django_airavata/apps/api/view_utils.py b/django_airavata/apps/api/view_utils.py
index b1bdb70..1046684 100644
--- a/django_airavata/apps/api/view_utils.py
+++ b/django_airavata/apps/api/view_utils.py
@@ -10,6 +10,10 @@ from rest_framework.viewsets import GenericViewSet
class GenericAPIBackedViewSet(GenericViewSet):
+ # Make lookup_value_regex to any set of non-forward-slash characters. Many
+ # Airavata ids contains period ('.') which the default lookup_value_regex
+ # in DRF doesn't allow.
+ lookup_value_regex = '[^/]+'
def get_list(self):
"""
diff --git a/django_airavata/apps/api/views.py b/django_airavata/apps/api/views.py
index 12ad8fd..196d304 100644
--- a/django_airavata/apps/api/views.py
+++ b/django_airavata/apps/api/views.py
@@ -402,7 +402,6 @@ class ApplicationInterfaceViewSet(APIBackedViewSet):
class ApplicationDeploymentViewSet(APIBackedViewSet):
serializer_class = serializers.ApplicationDeploymentDescriptionSerializer
lookup_field = 'app_deployment_id'
- lookup_value_regex = '[^/]+'
def get_list(self):
app_module_id = self.request.query_params.get('appModuleId', None)
@@ -467,7 +466,6 @@ class ComputeResourceViewSet(mixins.RetrieveModelMixin,
GenericAPIBackedViewSet):
serializer_class = serializers.ComputeResourceDescriptionSerializer
lookup_field = 'compute_resource_id'
- lookup_value_regex = '[^/]+'
def get_instance(self, lookup_value, format=None):
return self.request.airavata_client.getComputeResource(
@@ -737,7 +735,6 @@ class SharedEntityViewSet(mixins.RetrieveModelMixin,
GenericAPIBackedViewSet):
serializer_class = serializers.SharedEntitySerializer
lookup_field = 'entity_id'
- lookup_value_regex = '[^/]+'
def get_instance(self, lookup_value):
users = {}
@@ -943,7 +940,6 @@ class CredentialSummaryViewSet(APIBackedViewSet):
class GatewayResourceProfileViewSet(APIBackedViewSet):
serializer_class = serializers.GatewayResourceProfileSerializer
lookup_field = 'gateway_id'
- lookup_value_regex = '[^/]+'
def get_list(self):
return self.request.airavata_client.getAllGatewayResourceProfiles(
@@ -985,7 +981,6 @@ class StorageResourceViewSet(mixins.RetrieveModelMixin,
GenericAPIBackedViewSet):
serializer_class = serializers.StorageResourceSerializer
lookup_field = 'storage_resource_id'
- lookup_value_regex = '[^/]+'
def get_instance(self, lookup_value, format=None):
return self.request.airavata_client.getStorageResource(
@@ -1002,7 +997,6 @@ class StorageResourceViewSet(mixins.RetrieveModelMixin,
class StoragePreferenceViewSet(APIBackedViewSet):
serializer_class = serializers.StoragePreferenceSerializer
lookup_field = 'storage_resource_id'
- lookup_value_regex = '[^/]+'
def get_list(self):
return self.request.airavata_client.getAllGatewayStoragePreferences(
@@ -1040,7 +1034,6 @@ class ParserViewSet(mixins.CreateModelMixin,
GenericAPIBackedViewSet):
serializer_class = serializers.ParserSerializer
lookup_field = 'parser_id'
- lookup_value_regex = '[^/]+'
def get_list(self):
return self.request.airavata_client.listAllParsers(self.authz_token, settings.GATEWAY_ID)
|