Skip to content
Snippets Groups Projects
Unverified Commit 89ef247f authored by Calen Pennington's avatar Calen Pennington Committed by GitHub
Browse files

Merge pull request #22368 from luismorenolopera/dmo/INCR-561

Convert @require_certificate_permission to use user.has_perm
parents d506ecc9 5c2818d3
No related branches found
No related tags found
No related merge requests found
......@@ -7,3 +7,5 @@ from lms.djangoapps.courseware.rules import HasAccessRule
PREVIEW_CERTIFICATES = 'certificates.preview_certificates'
perms[PREVIEW_CERTIFICATES] = HasAccessRule('staff')
VIEW_ALL_CERTIFICATES = 'certificates.view_all_certificates'
perms[VIEW_ALL_CERTIFICATES] = HasAccessRule('certificates')
......@@ -25,6 +25,7 @@ from opaque_keys.edx.keys import CourseKey
from lms.djangoapps.courseware.access import has_access
from lms.djangoapps.certificates import api
from lms.djangoapps.certificates.models import CertificateInvalidation
from lms.djangoapps.certificates.permissions import VIEW_ALL_CERTIFICATES
from lms.djangoapps.instructor_task.api import generate_certificates_for_students
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from student.models import CourseEnrollment, User
......@@ -40,7 +41,7 @@ def require_certificate_permission(func):
"""
@wraps(func)
def inner(request, *args, **kwargs):
if has_access(request.user, "certificates", "global"):
if request.user.has_perm(VIEW_ALL_CERTIFICATES, 'global'):
return func(request, *args, **kwargs)
else:
return HttpResponseForbidden()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment