Issue #276 changed check_nd_number_regex to receive a study and to filter out…
Issue #276 (closed) changed check_nd_number_regex to receive a study and to filter out null or blank nd_numbers in the studySubjects
Hi @piotr.gawron The problem here was that all StudySubjects are checked against this new regex, like this:
@staticmethod
def check_nd_number_regex(regex_str):
nd_numbers = StudySubject.objects.all().values_list('nd_number', flat=True)
regex = re.compile(regex_str)
for nd_number in nd_numbers:
if regex.match(nd_number) is None:
return False
return True
I changed this line
nd_numbers = StudySubject.objects.all().values_list('nd_number', flat=True)
for this:
nd_numbers = StudySubject.objects.exclude(nd_number__isnull=True).exclude(nd_number__exact='').all().values_list('nd_number', flat=True)
But I also noticed that I need to filter out only those StudySubjects from the study where the regex is going to be changed. So I fixed both things, and I added more stuff to the staticmethod.
Then the question is, what should we do if the instance in the StudyEditForm is None? Should never happen...