Skip to content

Commit

Permalink
Merge branch 'release/0.3.22' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Mar 8, 2024
2 parents 72aeb46 + cc349a0 commit 53d99b5
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 11 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ jobs:
sudo apt-get -y update
sudo apt-get install libcups2-dev wamerican
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -48,7 +48,7 @@ jobs:
echo "dir=$(pip cache dir)" >>$GITHUB_OUTPUT
- name: Cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key:
Expand Down
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@ exclude: tests/etc/user-*

repos:
- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
rev: 1.7.7
hooks:
- id: bandit
args:
- "-x *test*.py"

- repo: https://github.com/psf/black
rev: 23.9.1
rev: 24.2.0
hooks:
- id: black
language_version: python3.11

- repo: https://github.com/pycqa/flake8
rev: 6.1.0
rev: 7.0.0
hooks:
- id: flake8
args:
- "--config=setup.cfg"

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: requirements-txt-fixer
files: requirements/.*\.txt$
Expand All @@ -42,7 +42,7 @@ repos:
- id: detect-private-key

- repo: https://github.com/adrienverge/yamllint
rev: v1.32.0
rev: v1.34.0
hooks:
- id: yamllint
args:
Expand Down
13 changes: 13 additions & 0 deletions edc_prn/modelform_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from datetime import datetime

from edc_consent import site_consents
from edc_consent.consent_definition import ConsentDefinition
from edc_crf.crf_form_validator_mixins import BaseFormValidatorMixin


Expand All @@ -10,6 +12,17 @@ class PrnFormValidatorMixin(BaseFormValidatorMixin):

report_datetime_field_attr = "report_datetime"

@property
def subject_consent(self):
return self.get_consent_definition(
report_datetime=self.report_datetime
).model_cls.objects.get(subject_identifier=self.subject_identifier)

def get_consent_definition(
self, report_datetime: datetime = None, fldname: str = None, error_code: str = None
) -> ConsentDefinition:
return site_consents.get_consent_definition(report_datetime=self.report_datetime)

@property
def report_datetime(self) -> datetime:
"""Returns report_datetime or raises.
Expand Down
2 changes: 1 addition & 1 deletion edc_prn/tests/tests/test_prn_form_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class MyFormValidator(PrnFormValidatorMixin, FormValidator):

def clean(self) -> None:
"""test all methods"""
_ = self.subject_consent
# _ = self.subject_consent
_ = self.subject_identifier
_ = self.report_datetime

Expand Down
2 changes: 1 addition & 1 deletion prn_app/consents.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from edc_protocol.research_protocol_config import ResearchProtocolConfig

consent_v1 = ConsentDefinition(
"prn_app.subjectconsent",
"prn_app.subjectconsentv1",
version="1",
start=ResearchProtocolConfig().study_open_datetime,
end=ResearchProtocolConfig().study_close_datetime,
Expand Down
5 changes: 5 additions & 0 deletions prn_app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ class SubjectConsent(
dob = models.DateField(default=date(1995, 1, 1))


class SubjectConsentV1(SubjectConsent):
class Meta:
proxy = True


class SubjectScreening(ScreeningModelMixin, BaseUuidModel):
consent_definition = consent_v1
objects = SubjectIdentifierManager()
Expand Down

0 comments on commit 53d99b5

Please sign in to comment.