Skip to content

Commit a93e8ad

Browse files
committed
Merge branch 'release/0.3.89' into main
2 parents a4841da + 4b8b0e7 commit a93e8ad

File tree

9 files changed

+74
-59
lines changed

9 files changed

+74
-59
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ exclude: tests/etc/user-*
33

44
repos:
55
- repo: https://github.com/PyCQA/bandit
6-
rev: 1.7.10
6+
rev: 1.8.2
77
hooks:
88
- id: bandit
99
args:

edc_consent/field_mixins/review_fields_mixin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class ReviewFieldsMixin(models.Model):
5050

5151
consent_copy = models.CharField(
5252
verbose_name=(
53-
"I have provided the participant with a copy of their " "signed informed consent"
53+
"I have provided the participant with a copy of their signed informed consent"
5454
),
5555
max_length=20,
5656
choices=YES_NO_DECLINED,

edc_consent/model_mixins/consent_extension_model_mixin.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from django.db import models
22
from django.utils.translation import gettext as _
33
from django_crypto_fields.fields import EncryptedTextField
4-
from edc_constants.choices import YES_NO
4+
from edc_constants.choices import YES_NO_NA
55
from edc_identifier.model_mixins import UniqueSubjectIdentifierModelMixin
66
from edc_utils import get_utcnow
77

@@ -21,10 +21,11 @@ class ConsentExtensionModelMixin(UniqueSubjectIdentifierModelMixin, models.Model
2121

2222
agrees_to_extension = models.CharField(
2323
verbose_name=_(
24-
"Does the participant agree to extend followup as per the protocol amendment?"
24+
"Does the participant give consent to extend clinic "
25+
"followup as per the protocol amendment?"
2526
),
2627
max_length=15,
27-
choices=YES_NO,
28+
choices=YES_NO_NA,
2829
help_text=_("See above for the definition of extended followup."),
2930
)
3031

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
from .consent_modelform_mixin import ConsentModelFormMixin
1+
from .consent_modelform_mixin import ConsentModelFormMixin, ReviewFieldsModelFormMixin
22
from .requires_consent_modelform_mixin import RequiresConsentModelFormMixin
33

4-
__all__ = ["ConsentModelFormMixin", "RequiresConsentModelFormMixin"]
4+
__all__ = [
5+
"ConsentModelFormMixin",
6+
"RequiresConsentModelFormMixin",
7+
"ReviewFieldsModelFormMixin",
8+
]
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
from .consent_modelform_mixin import ConsentModelFormMixin
2+
from .review_fields_modelform_mixin import ReviewFieldsModelFormMixin
23

3-
__all__ = ["ConsentModelFormMixin"]
4+
__all__ = ["ConsentModelFormMixin", "ReviewFieldsModelFormMixin"]

edc_consent/modelform_mixins/consent_modelform_mixin/clean_fields_modelform_validation_mixin.py

Lines changed: 4 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@
33
from typing import TYPE_CHECKING
44

55
from django import forms
6-
from edc_constants.constants import NO, YES
76
from edc_screening.utils import (
87
get_subject_screening_model_cls,
98
get_subject_screening_or_raise,
109
)
1110

11+
from .review_fields_modelform_mixin import ReviewFieldsModelFormMixin
12+
1213
if TYPE_CHECKING:
1314
from edc_screening.model_mixins import ScreeningModelMixin
1415

15-
16-
class ConsentModelFormMixinError(Exception):
17-
pass
16+
___all__ = ["CleanFieldsModelFormValidationMixin"]
1817

1918

20-
class CleanFieldsModelFormValidationMixin:
19+
class CleanFieldsModelFormValidationMixin(ReviewFieldsModelFormMixin):
2120
"""A model form mixin calling the default `clean_xxxxx` django
2221
methods.
2322
@@ -42,51 +41,6 @@ def subject_screening(self):
4241
)
4342
return get_subject_screening_or_raise(screening_identifier, is_modelform=True)
4443

45-
def clean_consent_reviewed(self) -> str:
46-
consent_reviewed = self.cleaned_data.get("consent_reviewed")
47-
if consent_reviewed != YES:
48-
raise forms.ValidationError(
49-
"Complete this part of the informed consent process before continuing.",
50-
code="invalid",
51-
)
52-
return consent_reviewed
53-
54-
def clean_study_questions(self) -> str:
55-
study_questions = self.cleaned_data.get("study_questions")
56-
if study_questions != YES:
57-
raise forms.ValidationError(
58-
"Complete this part of the informed consent process before continuing.",
59-
code="invalid",
60-
)
61-
return study_questions
62-
63-
def clean_assessment_score(self) -> str:
64-
assessment_score = self.cleaned_data.get("assessment_score")
65-
if assessment_score != YES:
66-
raise forms.ValidationError(
67-
"Complete this part of the informed consent process before continuing.",
68-
code="invalid",
69-
)
70-
return assessment_score
71-
72-
def clean_consent_copy(self) -> str:
73-
consent_copy = self.cleaned_data.get("consent_copy")
74-
if consent_copy == NO:
75-
raise forms.ValidationError(
76-
"Complete this part of the informed consent process before continuing.",
77-
code="invalid",
78-
)
79-
return consent_copy
80-
81-
def clean_consent_signature(self) -> str:
82-
consent_signature = self.cleaned_data.get("consent_signature")
83-
if consent_signature != YES:
84-
raise forms.ValidationError(
85-
"Complete this part of the informed consent process before continuing.",
86-
code="invalid",
87-
)
88-
return consent_signature
89-
9044
def clean_initials(self) -> str:
9145
initials = self.cleaned_data.get("initials")
9246
if initials and initials != self.subject_screening.initials:

edc_consent/modelform_mixins/consent_modelform_mixin/consent_modelform_mixin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from .clean_fields_modelform_validation_mixin import CleanFieldsModelFormValidationMixin
44
from .consent_modelform_validation_mixin import ConsentModelFormValidationMixin
55

6+
__all__ = ["ConsentModelFormMixin"]
7+
68

79
class ConsentModelFormMixin(
810
CleanFieldsModelFormValidationMixin, ConsentModelFormValidationMixin

edc_consent/modelform_mixins/consent_modelform_mixin/consent_modelform_validation_mixin.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
from edc_model_form.utils import get_field_or_raise
1010
from edc_utils import AgeValueError, age, formatted_age
1111

12-
from ... import site_consents
1312
from ...exceptions import ConsentDefinitionValidityPeriodError
13+
from ...site_consents import site_consents
1414
from ...utils import InvalidInitials, verify_initials_against_full_name
1515

1616
if TYPE_CHECKING:
1717
from ...consent_definition import ConsentDefinition
1818

19+
___all__ = ["ConsentModelFormValidationMixin"]
20+
1921

2022
class ConsentModelFormValidationMixin:
2123
"""A mixin for the consent ModelForm consisting of validation
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
from django import forms
2+
from edc_constants.constants import NO, YES
3+
4+
___all__ = ["ReviewFieldsModelFormMixin"]
5+
6+
7+
class ReviewFieldsModelFormMixin:
8+
def clean_consent_reviewed(self) -> str:
9+
consent_reviewed = self.cleaned_data.get("consent_reviewed")
10+
if consent_reviewed != YES:
11+
raise forms.ValidationError(
12+
"Complete this part of the informed consent process before continuing.",
13+
code="invalid",
14+
)
15+
return consent_reviewed
16+
17+
def clean_study_questions(self) -> str:
18+
study_questions = self.cleaned_data.get("study_questions")
19+
if study_questions != YES:
20+
raise forms.ValidationError(
21+
"Complete this part of the informed consent process before continuing.",
22+
code="invalid",
23+
)
24+
return study_questions
25+
26+
def clean_assessment_score(self) -> str:
27+
assessment_score = self.cleaned_data.get("assessment_score")
28+
if assessment_score != YES:
29+
raise forms.ValidationError(
30+
"Complete this part of the informed consent process before continuing.",
31+
code="invalid",
32+
)
33+
return assessment_score
34+
35+
def clean_consent_copy(self) -> str:
36+
consent_copy = self.cleaned_data.get("consent_copy")
37+
if consent_copy == NO:
38+
raise forms.ValidationError(
39+
"Complete this part of the informed consent process before continuing.",
40+
code="invalid",
41+
)
42+
return consent_copy
43+
44+
def clean_consent_signature(self) -> str:
45+
consent_signature = self.cleaned_data.get("consent_signature")
46+
if consent_signature != YES:
47+
raise forms.ValidationError(
48+
"Complete this part of the informed consent process before continuing.",
49+
code="invalid",
50+
)
51+
return consent_signature

0 commit comments

Comments
 (0)