Skip to content
Snippets Groups Projects
Commit 72503e4e authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch...

Merge branch '383-saving-subject-with-custom-date_field-makes-subject-form-unusable' into 'devel_1.0.x'

Resolve "saving subject with custom date_field makes subject form unusable"

See merge request NCER-PD/scheduling-system!310
parents 07dc55c9 e9b0e927
No related branches found
No related tags found
3 merge requests!316Merge 1.0.1,!3151.0.1 into master,!310Resolve "saving subject with custom date_field makes subject form unusable"
Pipeline #38447 passed
...@@ -3,6 +3,8 @@ smasch (1.0.1-1) stable; urgency=low ...@@ -3,6 +3,8 @@ smasch (1.0.1-1) stable; urgency=low
* bug fix: unfinish visit button was always disabled (#386) * bug fix: unfinish visit button was always disabled (#386)
* bug fix: generating documents for templates did not work for subjects * bug fix: generating documents for templates did not work for subjects
created before custom field was added to the study (#388) created before custom field was added to the study (#388)
* bug fix: readonly custom Date Field was improperly persisted in forms
(#383)
-- Piotr Gawron <piotr.gawron@uni.lu> Mon, 15 Mar 2021 14:00:00 +0200 -- Piotr Gawron <piotr.gawron@uni.lu> Mon, 15 Mar 2021 14:00:00 +0200
......
...@@ -7,8 +7,8 @@ from django.forms import ModelForm ...@@ -7,8 +7,8 @@ from django.forms import ModelForm
from web.forms.forms import DATETIMEPICKER_DATE_ATTRS, get_worker_from_args, DATEPICKER_DATE_ATTRS from web.forms.forms import DATETIMEPICKER_DATE_ATTRS, get_worker_from_args, DATEPICKER_DATE_ATTRS
from web.models import StudySubject, Study, StudyColumns, VoucherType, Worker from web.models import StudySubject, Study, StudyColumns, VoucherType, Worker
from web.models.constants import SCREENING_NUMBER_PREFIXES_FOR_TYPE, CUSTOM_FIELD_TYPE_TEXT, CUSTOM_FIELD_TYPE_BOOLEAN, \ from web.models.constants import SCREENING_NUMBER_PREFIXES_FOR_TYPE, CUSTOM_FIELD_TYPE_TEXT, \
CUSTOM_FIELD_TYPE_INTEGER, CUSTOM_FIELD_TYPE_DOUBLE, \ CUSTOM_FIELD_TYPE_BOOLEAN, CUSTOM_FIELD_TYPE_INTEGER, CUSTOM_FIELD_TYPE_DOUBLE, \
CUSTOM_FIELD_TYPE_DATE, CUSTOM_FIELD_TYPE_SELECT_LIST, CUSTOM_FIELD_TYPE_FILE CUSTOM_FIELD_TYPE_DATE, CUSTOM_FIELD_TYPE_SELECT_LIST, CUSTOM_FIELD_TYPE_FILE
from web.models.custom_data import CustomStudySubjectField, CustomStudySubjectValue from web.models.custom_data import CustomStudySubjectField, CustomStudySubjectValue
from web.models.custom_data.custom_study_subject_field import get_study_subject_field_id from web.models.custom_data.custom_study_subject_field import get_study_subject_field_id
...@@ -158,8 +158,9 @@ class StudySubjectAddForm(StudySubjectForm): ...@@ -158,8 +158,9 @@ class StudySubjectAddForm(StudySubjectForm):
instance = super(StudySubjectAddForm, self).save(commit) instance = super(StudySubjectAddForm, self).save(commit)
# we can add custom values only after object exists in the database # we can add custom values only after object exists in the database
for field_type in CustomStudySubjectField.objects.filter(study=self.study): for field_type in CustomStudySubjectField.objects.filter(study=self.study):
self.instance.set_custom_data_value(field_type, get_study_subject_field_value(field_type, self[ if not field_type.readonly:
get_study_subject_field_id(field_type)])) self.instance.set_custom_data_value(field_type, get_study_subject_field_value(field_type, self[
get_study_subject_field_id(field_type)]))
return instance return instance
def build_screening_number(self, cleaned_data): def build_screening_number(self, cleaned_data):
...@@ -289,8 +290,9 @@ class StudySubjectEditForm(StudySubjectForm): ...@@ -289,8 +290,9 @@ class StudySubjectEditForm(StudySubjectForm):
def save(self, commit=True) -> StudySubject: def save(self, commit=True) -> StudySubject:
for field_type in CustomStudySubjectField.objects.filter(study=self.study): for field_type in CustomStudySubjectField.objects.filter(study=self.study):
self.instance.set_custom_data_value(field_type, get_study_subject_field_value(field_type, self[ if not field_type.readonly:
get_study_subject_field_id(field_type)])) self.instance.set_custom_data_value(field_type, get_study_subject_field_value(field_type, self[
get_study_subject_field_id(field_type)]))
return super(StudySubjectForm, self).save(commit) return super(StudySubjectForm, self).save(commit)
class Meta: class Meta:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment