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

don't validate screening number when screeing number is disabled

parent 256535d7
No related branches found
No related tags found
1 merge request!414Resolve "adding subject while screening number is unable throws Internet server error"
Pipeline #53657 passed
smasch (1.1.0~beta.1-1) unstable; urgency=low
* bug fix: impossible to add subject when screening number is disabled (#501)
-- Piotr Gawron <piotr.gawron@uni.lu> Mon, 4 Mar 2022 16:00:00 +0200
smasch (1.1.0~beta.0-1) unstable; urgency=low
* improvement: allow to assign empty value to email configuration option so
......
......@@ -347,7 +347,7 @@ def prepare_study_subject_fields(fields, study: Study):
def validate_subject_screening_number(self, cleaned_data):
if self.study.columns.resign_reason:
if self.study.columns.resign_reason and self.study.columns.screening_number:
subjects_from_db = StudySubject.objects.filter(screening_number=cleaned_data["screening_number"],
study=self.study)
if len(subjects_from_db) > 0:
......
......@@ -258,7 +258,7 @@ desired effect
{% block footer %}
<!-- To the right -->
<div class="pull-right hidden-xs">
Version: <strong>1.1.0~beta.0</strong>
Version: <strong>1.1.0~beta.1</strong>
</div>
<!-- Default to the left -->
......
......@@ -399,3 +399,15 @@ class SubjectsViewTests(LoggedInTestCase):
self.assertEqual(response.status_code, 302)
updated_study_subject = StudySubject.objects.get(id=self.study_subject.id)
self.assertTrue(updated_study_subject.subject.dead)
def test_subjects_add_when_screening_number_disabled(self):
self.study.columns.screening_number = False
self.study.columns.save()
self.worker.roles.all()[0].permissions.add(Permission.objects.get(codename="add_subject"))
self.worker.save()
form_data = self.create_add_form_data_for_study_subject()
count = StudySubject.objects.all().count()
self.client.post(reverse('web.views.subject_add', kwargs={'study_id': self.study.id}), data=form_data)
self.assertEqual(count + 1, StudySubject.objects.all().count())
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