Skip to content

Commit

Permalink
ensure list of consents is unique for view
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Mar 1, 2024
1 parent aaaa2e4 commit 002c197
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions edc_consent/view_mixins/consent_view_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ def consents(self) -> QuerySet[ConsentLikeModel]:
if not self._consents:
self._consents = []
for cdef in site_consents.get_consent_definitions():
if obj := cdef.get_consent_for(
subject_identifier=self.subject_identifier,
raise_if_not_consented=False,
):
self._consents.append(obj)
try:
obj = cdef.get_consent_for(subject_identifier=self.subject_identifier)
except NotConsentedError:
pass
else:
if obj not in self._consents:
self._consents.append(obj)
return self._consents

@property
Expand Down

0 comments on commit 002c197

Please sign in to comment.