Skip to content

Commit

Permalink
Merge pull request #600 from edly-io/manan/EDLY-7237
Browse files Browse the repository at this point in the history
Added request and course exist check to avoid none type errors.
  • Loading branch information
manan-memon authored Nov 29, 2024
2 parents d8f7aaf + 0c836f7 commit 557077e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions common/djangoapps/student/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ def has_studio_write_access(user, course_key):
:param course_key: a CourseKey
"""
request = get_current_request()
if not is_course_org_same_as_site_org(request.site, course_key, is_studio=True):
site = getattr(request, 'site', None)

if course_key and site and not is_course_org_same_as_site_org(site, course_key, is_studio=True):
return False

return bool(STUDIO_EDIT_CONTENT & get_user_permissions(user, course_key))
Expand All @@ -140,7 +142,9 @@ def has_studio_read_access(user, course_key):
there is read-only access to content libraries.
"""
request = get_current_request()
if not is_course_org_same_as_site_org(request.site, course_key, is_studio=True):
site = getattr(request, 'site', None)

if course_key and site and not is_course_org_same_as_site_org(site, course_key, is_studio=True):
return False

return bool(STUDIO_VIEW_CONTENT & get_user_permissions(user, course_key))
Expand Down

0 comments on commit 557077e

Please sign in to comment.