Skip to content
Snippets Groups Projects

Feature/dummy data pdp

Merged Carlos Vega requested to merge feature/dummy_data_pdp into master
1 unresolved thread
14 files
+ 259
39
Compare changes
  • Side-by-side
  • Inline
Files
14
  • 5e114166
    added checks for forms
    added check function in Study and StudySubject to avoid repeating a regex inline
    removed previous checks in which the regex was rewritten
    now the used regex is the one defined in the given study
    added tests and migrations
    changed functions in tests/functions to adapt the tests
import logging
from django.forms import ModelForm
from web.models import Study, StudyNotificationParameters, StudyColumns
from django.forms import ModelForm, ValidationError
from web.models import Study, StudyNotificationParameters, StudyColumns, StudySubject
logger = logging.getLogger(__name__)
@@ -12,6 +11,16 @@ class StudyEditForm(ModelForm):
def __init__(self, *args, **kwargs):
super(StudyEditForm, self).__init__(*args, **kwargs)
def clean_nd_number_study_subject_regex(self):
nd_number_study_subject_regex = self.cleaned_data.get(
'nd_number_study_subject_regex')
if StudySubject.check_nd_number_regex(nd_number_study_subject_regex) == False:
raise ValidationError(
'Please enter a valid nd_number_study_subject_regex regex.')
return nd_number_study_subject_regex
class Meta:
model = Study
fields = '__all__'
@@ -21,7 +30,8 @@ class StudyEditForm(ModelForm):
class StudyNotificationParametersEditForm(ModelForm):
def __init__(self, *args, **kwargs):
super(StudyNotificationParametersEditForm, self).__init__(*args, **kwargs)
super(StudyNotificationParametersEditForm,
self).__init__(*args, **kwargs)
class Meta:
model = StudyNotificationParameters
Loading