Skip to content

Commit

Permalink
Create RO/TO endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
nas-tabchiche committed Dec 4, 2024
1 parent 09d652e commit 484d117
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
20 changes: 18 additions & 2 deletions backend/ebios_rm/serializers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from core.serializers import (
BaseModelSerializer,
FieldsRelatedField,
AssessmentReadSerializer,
)
from core.models import StoredLibrary, RiskMatrix
from .models import EbiosRMStudy, FearedEvent
from .models import EbiosRMStudy, FearedEvent, RoTo
from rest_framework import serializers
import logging

Expand Down Expand Up @@ -72,3 +71,20 @@ class FearedEventReadSerializer(BaseModelSerializer):
class Meta:
model = FearedEvent
fields = "__all__"


class RoToWriteSerializer(BaseModelSerializer):
class Meta:
model = RoTo
exclude = ["created_at", "updated_at", "folder"]


class RoToReadSerializer(BaseModelSerializer):
str = serializers.CharField(source="__str__")
ebios_rm_study = FieldsRelatedField()
folder = FieldsRelatedField()
fearead_events = FieldsRelatedField(many=True)

class Meta:
model = RoTo
fields = "__all__"
3 changes: 2 additions & 1 deletion backend/ebios_rm/urls.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from django.urls import include, path
from rest_framework import routers

from ebios_rm.views import EbiosRMStudyViewSet, FearedEventViewSet
from ebios_rm.views import EbiosRMStudyViewSet, FearedEventViewSet, RoToViewSet

router = routers.DefaultRouter()

router.register(r"studies", EbiosRMStudyViewSet, basename="studies")
router.register(r"feared-events", FearedEventViewSet, basename="feared-events")
router.register(r"ro-to", RoToViewSet, basename="ro-to")

urlpatterns = [
path("", include(router.urls)),
Expand Down
6 changes: 5 additions & 1 deletion backend/ebios_rm/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from core.views import BaseModelViewSet as AbstractBaseModelViewSet
from .models import EbiosRMStudy, FearedEvent
from .models import EbiosRMStudy, FearedEvent, RoTo
from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_page
from rest_framework.decorators import action
Expand Down Expand Up @@ -27,3 +27,7 @@ def status(self, request):

class FearedEventViewSet(BaseModelViewSet):
model = FearedEvent


class RoToViewSet(BaseModelViewSet):
model = RoTo

0 comments on commit 484d117

Please sign in to comment.