From 6c9ae6c3fd986ca4febeae76d080637221e92625 Mon Sep 17 00:00:00 2001 From: Kalev Takkis Date: Thu, 26 Oct 2023 18:42:30 +0100 Subject: [PATCH] fix: PUT request to siteobservationtag view now modifies group (issue 1189) --- viewer/serializers.py | 9 +++++++++ viewer/views.py | 10 +++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/viewer/serializers.py b/viewer/serializers.py index 381f5b83..a50ba840 100644 --- a/viewer/serializers.py +++ b/viewer/serializers.py @@ -1,4 +1,5 @@ import os +import logging from urllib.parse import urljoin from django.db.models import F @@ -28,6 +29,8 @@ from viewer.target_set_upload import sanitize_mol +logger = logging.getLogger(__name__) + _ISPYB_SAFE_QUERY_SET = ISpyBSafeQuerySet() @@ -648,6 +651,12 @@ class Meta: class SiteObservationTagSerializer(serializers.ModelSerializer): + + site_observations = serializers.PrimaryKeyRelatedField( + many=True, + queryset=models.SiteObservation.objects.all() + ) + class Meta: model = models.SiteObservationTag fields = '__all__' diff --git a/viewer/views.py b/viewer/views.py index f9f5396f..d9d72863 100644 --- a/viewer/views.py +++ b/viewer/views.py @@ -1206,7 +1206,7 @@ def create(self, request): class TagCategoryView(viewsets.ModelViewSet): """Set up and retrieve information about tag categories (api/tag_category). """ - queryset = models.TagCategory.objects.filter() + queryset = models.TagCategory.objects.all() serializer_class = serializers.TagCategorySerializer filterset_fields = ('id', 'category') @@ -1214,7 +1214,7 @@ class TagCategoryView(viewsets.ModelViewSet): class SiteObservationTagView(viewsets.ModelViewSet): """Set up/retrieve information about tags relating to Molecules (api/molecule_tag) """ - queryset = models.SiteObservationTag.objects.filter() + queryset = models.SiteObservationTag.objects.all() serializer_class = serializers.SiteObservationTagSerializer filterset_fields = ('id', 'tag', 'category', 'target', 'site_observations', 'mol_group') @@ -1222,7 +1222,7 @@ class SiteObservationTagView(viewsets.ModelViewSet): class SessionProjectTagView(viewsets.ModelViewSet): """Set up/retrieve information about tags relating to Session Projects. """ - queryset = models.SessionProjectTag.objects.filter() + queryset = models.SessionProjectTag.objects.all() serializer_class = serializers.SessionProjectTagSerializer filterset_fields = ('id', 'tag', 'category', 'target', 'session_projects') @@ -1232,7 +1232,7 @@ class TargetMoleculesView(ISpyBSafeQuerySet): to a Target. The idea is that a single call can return all target related information needed by the React front end in a single call. """ - queryset = models.Target.objects.filter() + queryset = models.Target.objects.all() serializer_class = serializers.TargetMoleculesSerializer filter_permissions = "project_id" filterset_fields = ("title",) @@ -1245,7 +1245,7 @@ class DownloadStructures(ISpyBSafeQuerySet): Note that old zip files are removed after one hour. """ - queryset = models.Target.objects.filter() + queryset = models.Target.objects.all() serializer_class = serializers.DownloadStructuresSerializer filter_permissions = "project_id" filterset_fields = ('title','id')