Skip to content

Commit

Permalink
Merge branch 'release/0.3.84'
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanWillitts committed Apr 24, 2024
2 parents 249ba60 + 4acf59f commit 3211d89
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
4 changes: 4 additions & 0 deletions edc_consent/consent_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@ def __post_init__(self):
raise ConsentDefinitionError(f"Invalid gender. Got {self.gender}.")
if not self.start.tzinfo:
raise ConsentDefinitionError(f"Naive datetime not allowed. Got {self.start}.")
elif str(self.start.tzinfo) != "UTC":
raise ConsentDefinitionError(f"Start date must be UTC. Got {self.start}.")
if not self.end.tzinfo:
raise ConsentDefinitionError(f"Naive datetime not allowed Got {self.end}.")
elif str(self.end.tzinfo) != "UTC":
raise ConsentDefinitionError(f"End date must be UTC. Got {self.end}.")
self.check_date_within_study_period()

@property
Expand Down
6 changes: 3 additions & 3 deletions edc_consent/site_consents.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.core.management.color import color_style
from django.utils.module_loading import import_module, module_has_submodule
from edc_sites.site import sites as site_sites
from edc_utils import ceil_secs, floor_secs, formatted_date
from edc_utils import ceil_secs, floor_secs, formatted_date, to_utc

from .exceptions import (
AlreadyRegistered,
Expand Down Expand Up @@ -141,7 +141,7 @@ def get_consent_or_raise(
subject_identifier=subject_identifier,
raise_if_not_consented=raise_if_not_consented,
)
if consent_obj and report_datetime < consent_obj.consent_datetime:
if consent_obj and to_utc(report_datetime) < consent_obj.consent_datetime:
if not cdef.updates:
dte = formatted_date(report_datetime)
raise ConsentDefinitionNotConfiguredForUpdate(
Expand Down Expand Up @@ -257,7 +257,7 @@ def _filter_cdefs_by_report_datetime_or_raise(
cdefs = [
cdef
for cdef in cdefs
if floor_secs(cdef.start) <= report_datetime <= ceil_secs(cdef.end)
if floor_secs(cdef.start) <= to_utc(report_datetime) <= ceil_secs(cdef.end)
]
if not cdefs:
date_string = formatted_date(report_datetime)
Expand Down
17 changes: 7 additions & 10 deletions edc_consent/view_mixins/consent_view_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,14 @@ def __init__(self, **kwargs):
super().__init__(**kwargs)

def get_context_data(self, **kwargs) -> dict[str, Any]:
"""Add consent to the dashboard only if subject
is still on a schedule.
"""
"""Add consent_definition and consents to the dashboard."""
# TODO: What if active on more than one schedule??
if self.current_schedule:
try:
kwargs.update(consent_definition=self.consent_definition)
except ConsentDefinitionDoesNotExist as e:
messages.add_message(self.request, message=str(e), level=ERROR)
else:
kwargs.update(consent=self.consent, consents=self.consents)
try:
kwargs.update(consent_definition=self.consent_definition)
except ConsentDefinitionDoesNotExist as e:
messages.add_message(self.request, message=str(e), level=ERROR)
else:
kwargs.update(consent=self.consent, consents=self.consents)
return super().get_context_data(**kwargs)

@property
Expand Down

0 comments on commit 3211d89

Please sign in to comment.