Skip to content
Snippets Groups Projects

1.0.1 into master

Closed Piotr Gawron requested to merge devel_1.0.x into master
2 files
+ 11
6
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -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.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, \
CUSTOM_FIELD_TYPE_INTEGER, CUSTOM_FIELD_TYPE_DOUBLE, \
from web.models.constants import SCREENING_NUMBER_PREFIXES_FOR_TYPE, CUSTOM_FIELD_TYPE_TEXT, \
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
from web.models.custom_data import CustomStudySubjectField, CustomStudySubjectValue
from web.models.custom_data.custom_study_subject_field import get_study_subject_field_id
@@ -158,8 +158,9 @@ class StudySubjectAddForm(StudySubjectForm):
instance = super(StudySubjectAddForm, self).save(commit)
# we can add custom values only after object exists in the database
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[
get_study_subject_field_id(field_type)]))
if not field_type.readonly:
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
def build_screening_number(self, cleaned_data):
@@ -289,8 +290,9 @@ class StudySubjectEditForm(StudySubjectForm):
def save(self, commit=True) -> StudySubject:
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[
get_study_subject_field_id(field_type)]))
if not field_type.readonly:
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)
class Meta:
Loading