From: Diane Trout Date: Wed, 27 Jun 2012 22:56:37 +0000 (-0700) Subject: Only allow one default cluster station or sequencer to be set X-Git-Tag: v0.5.5~2 X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=commitdiff_plain;h=eff287e0df7a104a140e3e04cb636219ad01f50b Only allow one default cluster station or sequencer to be set Works by watching for the pre_save signal for those classes and if it sees that the isdefault flag being set to true it goes through all the other records and sets isdefault to null. --- diff --git a/htsworkflow/frontend/experiments/models.py b/htsworkflow/frontend/experiments/models.py index 20131e4..1b3674c 100644 --- a/htsworkflow/frontend/experiments/models.py +++ b/htsworkflow/frontend/experiments/models.py @@ -71,7 +71,7 @@ class ClusterStation(models.Model): """Clear default if needed """ if instance.isdefault: - for c in ClusterStation.objects.all(): + for c in ClusterStation.objects.filter(isdefault=True).all(): if c.id != instance.id: c.isdefault = False c.save() @@ -118,7 +118,7 @@ class Sequencer(models.Model): """Clear default if needed """ if instance.isdefault: - for s in Sequencer.objects.all(): + for s in Sequencer.objects.filter(isdefault=True).all(): if s.id != instance.id: s.isdefault = False s.save()