From 833dbae9a2a22b04c9299dfc825da93fa940452a Mon Sep 17 00:00:00 2001 From: Jonathan Willitts Date: Tue, 17 Sep 2024 19:34:54 +0100 Subject: [PATCH 1/2] Remove redundant enumerate --- edc_consent/consent_definition.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edc_consent/consent_definition.py b/edc_consent/consent_definition.py index 7854d4c..3f3611e 100644 --- a/edc_consent/consent_definition.py +++ b/edc_consent/consent_definition.py @@ -174,7 +174,7 @@ def check_date_within_study_period(self) -> None: protocol = ResearchProtocolConfig() study_open_datetime = protocol.study_open_datetime study_close_datetime = protocol.study_close_datetime - for index, attr in enumerate(["start", "end"]): + for attr in ["start", "end"]: if not ( floor_secs(study_open_datetime) <= getattr(self, attr) From 2606fed21c74cc3d348b4ed9870582c9b9441713 Mon Sep 17 00:00:00 2001 From: Jonathan Willitts Date: Tue, 17 Sep 2024 19:36:06 +0100 Subject: [PATCH 2/2] Update exception/error text - Fix typo - Add study open/close dates --- edc_consent/consent_definition.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/edc_consent/consent_definition.py b/edc_consent/consent_definition.py index 3f3611e..3f9d7f1 100644 --- a/edc_consent/consent_definition.py +++ b/edc_consent/consent_definition.py @@ -180,10 +180,15 @@ def check_date_within_study_period(self) -> None: <= getattr(self, attr) <= ceil_secs(study_close_datetime) ): - date_string = formatted_datetime(getattr(self, attr)) + open_date_string = formatted_datetime(study_open_datetime) + close_date_string = formatted_datetime(study_close_datetime) + attr_date_string = formatted_datetime(getattr(self, attr)) raise ConsentDefinitionError( - f"Invalid {attr} date. Cannot be before study start date. " - f"See {self}. Got {date_string}." + f"Invalid {attr} date. " + f"Must be within the opening and closing dates of the protocol. " + f"See {self}. " + f"Got {open_date_string=}, {close_date_string=}, " + f"{attr=}, {attr_date_string=}." ) def get_previous_consent(