Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(projects): Fixed an issue on DataProject view with un-authenticat… #696

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions app/projects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ def panel_institutional_official(self, context):

try:
# Check for an institutional official linked to this user
official = InstitutionalOfficial.objects.get(user=self.participant.user)
official = InstitutionalOfficial.objects.get(user=self.request.user)

# Add to context
additional_context["official"] = official
Expand All @@ -809,7 +809,7 @@ def panel_institutional_official(self, context):

try:
# Check for an institutional member linked to this user
member = InstitutionalMember.objects.get(user=self.participant.user)
member = InstitutionalMember.objects.get(email=self.request.user.email)

# Add to context
additional_context["member"] = member
Expand Down Expand Up @@ -933,16 +933,18 @@ def is_user_granted_access(self, context):
"""
# Check for institutional access
try:
member = InstitutionalMember.objects.get(official__project=self.project, email=self.request.user.email)
logger.debug(f"Institutional member found under official: {member.official.user.email}")

# Check if official has access
official_participant = Participant.objects.get(project=self.project, user=member.official.user)
if official_participant.permission == "VIEW":
logger.debug(f"Institutional official has access, granting access to member")
return True
else:
logger.debug(f"Institutional official does not have access")
# Only perform this check for authenticated users
if self.request.user.is_authenticated:
member = InstitutionalMember.objects.get(official__project=self.project, email=self.request.user.email)
logger.debug(f"Institutional member found under official: {member.official.user.email}")

# Check if official has access
official_participant = Participant.objects.get(project=self.project, user=member.official.user)
if official_participant.permission == "VIEW":
logger.debug(f"Institutional official has access, granting access to member")
return True
else:
logger.debug(f"Institutional official does not have access")

except ObjectDoesNotExist:
logger.debug(f"No institutional member found")
Expand Down
Loading