Merge pull request #23034 from edx/azarembok/cert-url

PROD-1236: Change URL returned for generated certificates to use UUID.
This commit is contained in:
Alan Zarembok
2020-02-10 08:18:12 -05:00
committed by GitHub
3 changed files with 7 additions and 8 deletions

View File

@@ -69,7 +69,8 @@ def format_certificate_for_user(username, cert):
"is_passing": is_passing_status(cert.status),
"is_pdf_certificate": bool(cert.download_url),
"download_url": (
cert.download_url or get_certificate_url(cert.user.id, cert.course_id, user_certificate=cert)
cert.download_url or get_certificate_url(cert.user.id, cert.course_id, uuid=cert.verify_uuid,
user_certificate=cert)
if cert.status == CertificateStatuses.downloadable
else None
),

View File

@@ -381,6 +381,6 @@ class CertificatesListRestApiTest(AuthAndScopesTestMixin, SharedModuleStoreTestC
requesting_user=self.student,
requested_user=self.student,
)
kwargs = {"user_id": str(self.student.id), "course_id": six.text_type(self.course.id)}
expected_download_url = reverse('certificates:html_view', kwargs=kwargs)
kwargs = {"certificate_uuid": self.cert.verify_uuid}
expected_download_url = reverse('certificates:render_cert_by_uuid', kwargs=kwargs)
self.assert_success_response_for_student(response, download_url=expected_download_url)

View File

@@ -13,7 +13,7 @@ from edx_rest_framework_extensions.auth.session.authentication import SessionAut
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey
from rest_condition import C
from rest_framework.generics import GenericAPIView
from rest_framework.views import APIView
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
@@ -28,7 +28,7 @@ log = logging.getLogger(__name__)
User = get_user_model()
class CertificatesDetailView(GenericAPIView):
class CertificatesDetailView(APIView):
"""
**Use Case**
@@ -143,14 +143,13 @@ class CertificatesDetailView(GenericAPIView):
)
class CertificatesListView(GenericAPIView):
class CertificatesListView(APIView):
"""REST API endpoints for listing certificates."""
authentication_classes = (
JwtAuthentication,
OAuth2AuthenticationAllowInactiveUserDeprecated,
SessionAuthenticationAllowInactiveUser,
)
permission_classes = (
C(IsAuthenticated) & (
C(permissions.NotJwtRestrictedApplication) |
@@ -239,7 +238,6 @@ class CertificatesListView(GenericAPIView):
'download_url': user_cert.get('download_url'),
'grade': user_cert.get('grade'),
})
return Response(user_certs)
def _viewable_by_requestor(self, request, username):