From 2f878bb4b85e294467ff7246a912de2550a8fbc6 Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Mon, 4 Dec 2017 11:21:43 +0100 Subject: [PATCH] columns are also hidden in study subject details form --- smash/web/forms/study_subject_forms.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/smash/web/forms/study_subject_forms.py b/smash/web/forms/study_subject_forms.py index a8743d14..8fab21fc 100644 --- a/smash/web/forms/study_subject_forms.py +++ b/smash/web/forms/study_subject_forms.py @@ -88,6 +88,18 @@ class StudySubjectDetailForm(ModelForm): model = StudySubject fields = '__all__' + def __init__(self, *args, **kwargs): + super(StudySubjectDetailForm, self).__init__(*args, **kwargs) + instance = getattr(self, 'instance', None) + + prepare_study_subject_fields(fields=self.fields, study=self.study) + +def get_study_from_study_subject_instance(study_subject): + if instance and instance.study_id: + self.study = Study.objects.filter(id=instance.study_id)[0] + else: + self.study = Study(columns=StudyColumns()) + class StudySubjectEditForm(ModelForm): datetime_contact_reminder = forms.DateTimeField(label="Contact on", -- GitLab