Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add lookup_value_regex to allow special char in url #821

Merged
merged 4 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class CommentViewSet(mixins.CreateModelMixin, mixins.UpdateModelMixin, mixins.Li
search_fields = Comment.get_base_fields()
http_method_names = ['get', 'post', 'patch', 'delete']
pagination_class = None
lookup_value_regex = "[^/]+" # to allow id prefix

def get_queryset(self):
return Comment.objects.filter(
Expand All @@ -41,16 +42,11 @@ def create(self, request, *args, **kwargs):
# Add workflow_run_id to the request data
mutable_data = request.data.copy()
mutable_data['association_id'] = seq_orcabus_id

serializer = self.get_serializer(data=mutable_data)
serializer.is_valid(raise_exception=True)
self.perform_create(serializer)
comment_obj = Comment.objects.create( **mutable_data)
serializer = self.get_serializer(comment_obj)
headers = self.get_success_headers(serializer.data)
return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)

def perform_create(self, serializer):
serializer.save() # Assuming you're using email as the user identifier

def update(self, request, *args, **kwargs):
partial = kwargs.pop('partial', False)
instance = self.get_object()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class StateViewSet(mixins.ListModelMixin, GenericViewSet):
serializer_class = StateSerializer
search_fields = State.get_base_fields()
pagination_class = None
lookup_value_regex = "[^/]+" # to allow id prefix

def get_queryset(self):
return State.objects.filter(sequence=self.kwargs["orcabus_id"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class StateViewSet(mixins.CreateModelMixin, mixins.UpdateModelMixin, mixins.List
search_fields = State.get_base_fields()
http_method_names = ['get', 'post', 'patch']
pagination_class = None
lookup_value_regex = "[^/]+" # to allow id prefix

"""
valid_states_map for state creation, update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class WorkflowRunCommentViewSet(mixins.CreateModelMixin, mixins.UpdateModelMixin
search_fields = WorkflowRunComment.get_base_fields()
http_method_names = ['get', 'post', 'patch', 'delete']
pagination_class = None
lookup_value_regex = "[^/]+" # to allow id prefix

def get_queryset(self):
return WorkflowRunComment.objects.filter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class WorkflowRunStatsViewSet(mixins.ListModelMixin, GenericViewSet):
serializer_class = WorkflowRunDetailSerializer
pagination_class = None # No pagination by default
http_method_names = ['get']
lookup_value_regex = "[^/]+" # to allow id prefix

def get_queryset(self):
"""
Expand Down
Loading