From 8e82af7bc32d89fb8f6e6087de436c1850c1bb85 Mon Sep 17 00:00:00 2001 From: AaronStephenson Date: Wed, 23 Aug 2017 23:27:39 -0500 Subject: [PATCH] Add Final Concentrated Sample Volume fields to Sample serializer --- lideservices/models.py | 4 ++-- lideservices/serializers.py | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lideservices/models.py b/lideservices/models.py index cc331f5..b3a05a8 100644 --- a/lideservices/models.py +++ b/lideservices/models.py @@ -248,8 +248,8 @@ class FinalConcentratedSampleVolume(HistoryModel): Final Concentrated Sample Volume """ - sample = models.ForeignKey('Sample') - concentration_type = models.ForeignKey('ConcentrationType') + sample = models.ForeignKey('Sample', related_name='final_concentrated_sample_volumes') + concentration_type = models.ForeignKey('ConcentrationType', related_name='final_concentrated_sample_volumes') final_concentrated_sample_volume = models.FloatField(null=True, blank=True) final_concentrated_sample_volume_notes = models.TextField(blank=True) diff --git a/lideservices/serializers.py b/lideservices/serializers.py index 4980d42..147493b 100644 --- a/lideservices/serializers.py +++ b/lideservices/serializers.py @@ -11,6 +11,13 @@ class SampleSerializer(serializers.ModelSerializer): + final_concentrated_sample_volume = serializers.FloatField( + source='final_concentrated_sample_volumes.final_concentrated_sample_volume', read_only=True) + final_concentrated_sample_volume_type = serializers.StringRelatedField( + source='final_concentrated_sample_volumes.concentration_type', read_only=True) + final_concentrated_sample_volume_notes = serializers.CharField( + source='final_concentrated_sample_volumes.final_concentrated_sample_volume_notes', read_only=True) + class Meta: model = Sample fields = ('id', 'sample_type', 'matrix_type', 'filter_type', 'study', 'study_site_name', @@ -20,14 +27,16 @@ class Meta: 'total_volume_sampled_initial', 'total_volume_sampled_unit_initial', 'total_volume_sampled', 'sample_volume_initial', 'sample_volume_filtered', 'filter_born_on_date', 'filter_flag', 'secondary_concentration_flag', 'elution_date', 'elution_notes', 'technician_initials', - 'air_subsample_volume', 'post_dilution_volume', 'pump_flow_rate', 'analysisbatches',) + 'air_subsample_volume', 'post_dilution_volume', 'pump_flow_rate', 'analysisbatches', + 'final_concentrated_sample_volume', 'final_concentrated_sample_volume_type', + 'final_concentrated_sample_volume_notes',) class AliquotSerializer(serializers.ModelSerializer): class Meta: model = Aliquot - fields = ('id', 'sample', 'aliquot', 'frozen', 'freezer_location') + fields = ('id', 'sample', 'aliquot', 'frozen', 'freezer_location',) class SampleTypeSerializer(serializers.ModelSerializer): @@ -76,7 +85,7 @@ class FreezerLocationSerializer(serializers.ModelSerializer): class Meta: model = FreezerLocation - fields = ('id', 'freezer', 'rack', 'box', 'row', 'spot') + fields = ('id', 'freezer', 'rack', 'box', 'row', 'spot',) class FreezerSerializer(serializers.ModelSerializer):