diff --git a/client/src/store/index.ts b/client/src/store/index.ts index 6065159d..94216a81 100644 --- a/client/src/store/index.ts +++ b/client/src/store/index.ts @@ -336,7 +336,7 @@ const { forwardTo: currentFrame.nextFrame, upTo: currentFrame.firstFrameInPreviousScan, downTo: currentFrame.firstFrameInNextScan, - currentAutoEvaluation: currentFrame.auto_evaluation, + currentAutoEvaluation: currentFrame.frame_evaluation, autoWindow: experiment.autoWindow, autoLevel: experiment.autoLevel, }; diff --git a/miqa/core/migrations/0019_unique_evaluation.py b/miqa/core/migrations/0019_unique_evaluation.py new file mode 100644 index 00000000..8ce7b0fe --- /dev/null +++ b/miqa/core/migrations/0019_unique_evaluation.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.8 on 2021-11-06 16:46 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0018_image_to_frame'), + ] + + operations = [ + migrations.AlterField( + model_name='evaluation', + name='frame', + field=models.OneToOneField( + on_delete=django.db.models.deletion.CASCADE, + related_name='frame_evaluation', + to='core.frame', + ), + ), + ] diff --git a/miqa/core/models/evaluation.py b/miqa/core/models/evaluation.py index a4609133..a6790322 100644 --- a/miqa/core/models/evaluation.py +++ b/miqa/core/models/evaluation.py @@ -5,7 +5,11 @@ class Evaluation(models.Model): id = models.UUIDField(primary_key=True, default=uuid4, editable=False) - frame = models.ForeignKey('Frame', null=False, on_delete=models.PROTECT) + frame = models.OneToOneField( + 'Frame', + on_delete=models.CASCADE, + related_name='frame_evaluation', + ) evaluation_model = models.CharField(max_length=50) results = models.JSONField() diff --git a/miqa/core/rest/frame.py b/miqa/core/rest/frame.py index e55aa91e..8770a1cf 100644 --- a/miqa/core/rest/frame.py +++ b/miqa/core/rest/frame.py @@ -22,17 +22,10 @@ class Meta: class FrameSerializer(serializers.ModelSerializer): class Meta: model = Frame - fields = ['id', 'frame_number', 'auto_evaluation'] + fields = ['id', 'frame_number', 'frame_evaluation'] ref_name = 'scan_frame' - auto_evaluation = serializers.SerializerMethodField() - - def get_auto_evaluation(self, frame_object): - try: - evaluation_object = Evaluation.objects.get(frame=frame_object) - return EvaluationSerializer(evaluation_object).data - except Evaluation.DoesNotExist: - return None + frame_evaluation = EvaluationSerializer() class FrameViewSet(ListModelMixin, GenericViewSet):