From eff287e0df7a104a140e3e04cb636219ad01f50b Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Wed, 27 Jun 2012 15:56:37 -0700 Subject: [PATCH] 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. --- htsworkflow/frontend/experiments/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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() -- 2.30.2