forked from botswana-harvard/edc-consent
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
73 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
from .consent_modelform_mixin import ConsentModelFormMixin | ||
from .consent_modelform_mixin import ConsentModelFormMixin, ReviewFieldsModelFormMixin | ||
from .requires_consent_modelform_mixin import RequiresConsentModelFormMixin | ||
|
||
__all__ = ["ConsentModelFormMixin", "RequiresConsentModelFormMixin"] | ||
__all__ = [ | ||
"ConsentModelFormMixin", | ||
"RequiresConsentModelFormMixin", | ||
"ReviewFieldsModelFormMixin", | ||
] |
3 changes: 2 additions & 1 deletion
3
edc_consent/modelform_mixins/consent_modelform_mixin/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .consent_modelform_mixin import ConsentModelFormMixin | ||
from .review_fields_modelform_mixin import ReviewFieldsModelFormMixin | ||
|
||
__all__ = ["ConsentModelFormMixin"] | ||
__all__ = ["ConsentModelFormMixin", "ReviewFieldsModelFormMixin"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
edc_consent/modelform_mixins/consent_modelform_mixin/review_fields_modelform_mixin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from django import forms | ||
from edc_constants.constants import NO, YES | ||
|
||
___all__ = ["ReviewFieldsModelFormMixin"] | ||
|
||
|
||
class ReviewFieldsModelFormMixin: | ||
def clean_consent_reviewed(self) -> str: | ||
consent_reviewed = self.cleaned_data.get("consent_reviewed") | ||
if consent_reviewed != YES: | ||
raise forms.ValidationError( | ||
"Complete this part of the informed consent process before continuing.", | ||
code="invalid", | ||
) | ||
return consent_reviewed | ||
|
||
def clean_study_questions(self) -> str: | ||
study_questions = self.cleaned_data.get("study_questions") | ||
if study_questions != YES: | ||
raise forms.ValidationError( | ||
"Complete this part of the informed consent process before continuing.", | ||
code="invalid", | ||
) | ||
return study_questions | ||
|
||
def clean_assessment_score(self) -> str: | ||
assessment_score = self.cleaned_data.get("assessment_score") | ||
if assessment_score != YES: | ||
raise forms.ValidationError( | ||
"Complete this part of the informed consent process before continuing.", | ||
code="invalid", | ||
) | ||
return assessment_score | ||
|
||
def clean_consent_copy(self) -> str: | ||
consent_copy = self.cleaned_data.get("consent_copy") | ||
if consent_copy == NO: | ||
raise forms.ValidationError( | ||
"Complete this part of the informed consent process before continuing.", | ||
code="invalid", | ||
) | ||
return consent_copy | ||
|
||
def clean_consent_signature(self) -> str: | ||
consent_signature = self.cleaned_data.get("consent_signature") | ||
if consent_signature != YES: | ||
raise forms.ValidationError( | ||
"Complete this part of the informed consent process before continuing.", | ||
code="invalid", | ||
) | ||
return consent_signature |