Skip to content
This repository has been archived by the owner on Jul 18, 2023. It is now read-only.

Commit

Permalink
Change relationship between Samples and Final Conc Samp Vol\n from 1:…
Browse files Browse the repository at this point in the history
…N to 1:1
  • Loading branch information
aaronstephenson committed Aug 25, 2017
1 parent 0a6f557 commit 43cd064
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
21 changes: 21 additions & 0 deletions lideservices/migrations/0006_auto_20170824_2149.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.2 on 2017-08-24 21:49
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('lideservices', '0005_auto_20170823_2334'),
]

operations = [
migrations.AlterField(
model_name='finalconcentratedsamplevolume',
name='sample',
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='final_concentrated_sample_volume', to='lideservices.Sample'),
),
]
2 changes: 1 addition & 1 deletion lideservices/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class FinalConcentratedSampleVolume(HistoryModel):
Final Concentrated Sample Volume
"""

sample = models.ForeignKey('Sample', related_name='final_concentrated_sample_volumes')
sample = models.OneToOneField('Sample', related_name='final_concentrated_sample_volume')
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)
Expand Down
6 changes: 3 additions & 3 deletions lideservices/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
class SampleSerializer(serializers.ModelSerializer):

final_concentrated_sample_volume = serializers.FloatField(
source='final_concentrated_sample_volumes.final_concentrated_sample_volume', read_only=True)
source='final_concentrated_sample_volume.final_concentrated_sample_volume', read_only=True)
final_concentrated_sample_volume_type = serializers.StringRelatedField(
source='final_concentrated_sample_volumes.concentration_type', read_only=True)
source='final_concentrated_sample_volume.concentration_type.name', read_only=True)
final_concentrated_sample_volume_notes = serializers.CharField(
source='final_concentrated_sample_volumes.final_concentrated_sample_volume_notes', read_only=True)
source='final_concentrated_sample_volume.final_concentrated_sample_volume_notes', read_only=True)

class Meta:
model = Sample
Expand Down

0 comments on commit 43cd064

Please sign in to comment.