Skip to content

Commit 3211d89

Browse files
Merge branch 'release/0.3.84'
2 parents 249ba60 + 4acf59f commit 3211d89

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

edc_consent/consent_definition.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,12 @@ def __post_init__(self):
6969
raise ConsentDefinitionError(f"Invalid gender. Got {self.gender}.")
7070
if not self.start.tzinfo:
7171
raise ConsentDefinitionError(f"Naive datetime not allowed. Got {self.start}.")
72+
elif str(self.start.tzinfo) != "UTC":
73+
raise ConsentDefinitionError(f"Start date must be UTC. Got {self.start}.")
7274
if not self.end.tzinfo:
7375
raise ConsentDefinitionError(f"Naive datetime not allowed Got {self.end}.")
76+
elif str(self.end.tzinfo) != "UTC":
77+
raise ConsentDefinitionError(f"End date must be UTC. Got {self.end}.")
7478
self.check_date_within_study_period()
7579

7680
@property

edc_consent/site_consents.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from django.core.management.color import color_style
1010
from django.utils.module_loading import import_module, module_has_submodule
1111
from edc_sites.site import sites as site_sites
12-
from edc_utils import ceil_secs, floor_secs, formatted_date
12+
from edc_utils import ceil_secs, floor_secs, formatted_date, to_utc
1313

1414
from .exceptions import (
1515
AlreadyRegistered,
@@ -141,7 +141,7 @@ def get_consent_or_raise(
141141
subject_identifier=subject_identifier,
142142
raise_if_not_consented=raise_if_not_consented,
143143
)
144-
if consent_obj and report_datetime < consent_obj.consent_datetime:
144+
if consent_obj and to_utc(report_datetime) < consent_obj.consent_datetime:
145145
if not cdef.updates:
146146
dte = formatted_date(report_datetime)
147147
raise ConsentDefinitionNotConfiguredForUpdate(
@@ -257,7 +257,7 @@ def _filter_cdefs_by_report_datetime_or_raise(
257257
cdefs = [
258258
cdef
259259
for cdef in cdefs
260-
if floor_secs(cdef.start) <= report_datetime <= ceil_secs(cdef.end)
260+
if floor_secs(cdef.start) <= to_utc(report_datetime) <= ceil_secs(cdef.end)
261261
]
262262
if not cdefs:
263263
date_string = formatted_date(report_datetime)

edc_consent/view_mixins/consent_view_mixins.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,14 @@ def __init__(self, **kwargs):
2828
super().__init__(**kwargs)
2929

3030
def get_context_data(self, **kwargs) -> dict[str, Any]:
31-
"""Add consent to the dashboard only if subject
32-
is still on a schedule.
33-
"""
31+
"""Add consent_definition and consents to the dashboard."""
3432
# TODO: What if active on more than one schedule??
35-
if self.current_schedule:
36-
try:
37-
kwargs.update(consent_definition=self.consent_definition)
38-
except ConsentDefinitionDoesNotExist as e:
39-
messages.add_message(self.request, message=str(e), level=ERROR)
40-
else:
41-
kwargs.update(consent=self.consent, consents=self.consents)
33+
try:
34+
kwargs.update(consent_definition=self.consent_definition)
35+
except ConsentDefinitionDoesNotExist as e:
36+
messages.add_message(self.request, message=str(e), level=ERROR)
37+
else:
38+
kwargs.update(consent=self.consent, consents=self.consents)
4239
return super().get_context_data(**kwargs)
4340

4441
@property

0 commit comments

Comments
 (0)