diff --git a/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/serializers/state.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/serializers/state.py index 8059473ce..ce9aef77b 100644 --- a/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/serializers/state.py +++ b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/serializers/state.py @@ -1,6 +1,6 @@ from rest_framework import serializers -from sequence_run_manager.models import State +from sequence_run_manager.models import State, Sequence from sequence_run_manager.serializers.base import SerializersBase, OptionalFieldsMixin class StateBaseSerializer(SerializersBase): @@ -10,3 +10,8 @@ class StateSerializer(StateBaseSerializer): class Meta: model = State fields = "__all__" + + def to_representation(self, instance): + representation = super().to_representation(instance) + representation['sequence'] = Sequence.orcabus_id_prefix + representation['sequence'] + return representation diff --git a/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/urls/base.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/urls/base.py index 9a595e0bb..4a850fd30 100644 --- a/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/urls/base.py +++ b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/urls/base.py @@ -12,8 +12,9 @@ router = OptionalSlashDefaultRouter() router.register(r"sequence", SequenceViewSet, basename="sequence") -router.register("sequence/(?P[^/.]+)/state", StateViewSet, basename="sequence-state") -router.register("sequence/(?P[^/.]+)/comment", CommentViewSet, basename="sequence-comment") + +router.register("sequence//comment", CommentViewSet, basename="sequence-comment") +router.register("sequence//state", StateViewSet, basename="sequence-states") urlpatterns = [ path(f"{api_base}", include(router.urls)), diff --git a/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/viewsets/comment.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/viewsets/comment.py index 495b5b297..c00bba641 100644 --- a/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/viewsets/comment.py +++ b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/viewsets/comment.py @@ -9,8 +9,7 @@ from sequence_run_manager.models.sequence import Sequence from sequence_run_manager.serializers.comment import CommentSerializer - -class CommentViewSet(mixins.CreateModelMixin, mixins.UpdateModelMixin, mixins.DestroyModelMixin, GenericViewSet): +class CommentViewSet(mixins.CreateModelMixin, mixins.UpdateModelMixin, mixins.ListModelMixin, GenericViewSet): serializer_class = CommentSerializer search_fields = Comment.get_base_fields() orcabus_id_prefix = Comment.orcabus_id_prefix diff --git a/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/viewsets/state.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/viewsets/state.py index aa04b26af..3ec62824b 100644 --- a/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/viewsets/state.py +++ b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/viewsets/state.py @@ -1,15 +1,16 @@ from rest_framework.viewsets import GenericViewSet +from rest_framework import mixins from sequence_run_manager.models.state import State from sequence_run_manager.serializers.state import StateSerializer -class StateViewSet(GenericViewSet): +class StateViewSet(mixins.ListModelMixin, GenericViewSet): serializer_class = StateSerializer search_fields = State.get_base_fields() orcabus_id_prefix = State.orcabus_id_prefix - http_method_names = ['get'] pagination_class = None def get_queryset(self): return State.objects.filter(sequence=self.kwargs["orcabus_id"]) +