Merge pull request #27477 from edx/ciduarte/AA-723
fix: include VerifiedModeSerializerMixin in Progress Tab API [AA-723]
This commit is contained in:
@@ -3,6 +3,7 @@ Progress Tab Serializers
|
||||
"""
|
||||
from rest_framework import serializers
|
||||
from rest_framework.reverse import reverse
|
||||
from lms.djangoapps.course_home_api.mixins import VerifiedModeSerializerMixin
|
||||
|
||||
|
||||
class CourseGradeSerializer(serializers.Serializer):
|
||||
@@ -79,7 +80,7 @@ class VerificationDataSerializer(serializers.Serializer):
|
||||
status_date = serializers.DateTimeField()
|
||||
|
||||
|
||||
class ProgressTabSerializer(serializers.Serializer):
|
||||
class ProgressTabSerializer(VerifiedModeSerializerMixin):
|
||||
"""
|
||||
Serializer for progress tab
|
||||
"""
|
||||
|
||||
@@ -5,7 +5,7 @@ Tests for Progress Tab API in the Course Home API
|
||||
import dateutil
|
||||
import ddt
|
||||
import mock
|
||||
from datetime import timedelta
|
||||
from datetime import datetime, timedelta
|
||||
from pytz import UTC
|
||||
from unittest.mock import patch
|
||||
from django.urls import reverse
|
||||
@@ -19,7 +19,9 @@ from lms.djangoapps.course_home_api.tests.utils import BaseCourseHomeTests
|
||||
from lms.djangoapps.course_home_api.toggles import COURSE_HOME_MICROFRONTEND, COURSE_HOME_MICROFRONTEND_PROGRESS_TAB
|
||||
from lms.djangoapps.experiments.testutils import override_experiment_waffle_flag
|
||||
from lms.djangoapps.verify_student.models import ManualVerification
|
||||
from openedx.core.djangoapps.course_date_signals.utils import MIN_DURATION
|
||||
from openedx.core.djangoapps.user_api.preferences.api import set_user_preference
|
||||
from openedx.features.course_duration_limits.models import CourseDurationLimitConfig
|
||||
from xmodule.modulestore.tests.factories import ItemFactory
|
||||
|
||||
CREDIT_SUPPORT_URL = 'https://support.edx.org/hc/en-us/sections/115004154688-Purchasing-Academic-Credit'
|
||||
@@ -137,3 +139,15 @@ class ProgressTabTestViews(BaseCourseHomeTests):
|
||||
response = self.client.get(self.url)
|
||||
assert response.status_code == 200
|
||||
assert response.json()['user_has_passing_grade']
|
||||
|
||||
@override_experiment_waffle_flag(COURSE_HOME_MICROFRONTEND, active=True)
|
||||
@override_waffle_flag(COURSE_HOME_MICROFRONTEND_PROGRESS_TAB, active=True)
|
||||
def test_verified_mode(self):
|
||||
enrollment = CourseEnrollment.enroll(self.user, self.course.id)
|
||||
CourseDurationLimitConfig.objects.create(enabled=True, enabled_as_of=datetime(2018, 1, 1))
|
||||
|
||||
response = self.client.get(self.url)
|
||||
assert response.status_code == 200
|
||||
assert response.data['verified_mode'] == {'access_expiration_date': (enrollment.created + MIN_DURATION),
|
||||
'currency': 'USD', 'currency_symbol': '$', 'price': 149,
|
||||
'sku': 'ABCD1234', 'upgrade_url': '/dashboard'}
|
||||
|
||||
@@ -27,6 +27,7 @@ from lms.djangoapps.grades.api import CourseGradeFactory
|
||||
from lms.djangoapps.verify_student.services import IDVerificationService
|
||||
from openedx.core.djangoapps.content.block_structure.transformers import BlockStructureTransformers
|
||||
from openedx.core.djangoapps.content.block_structure.api import get_block_structure_manager
|
||||
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
|
||||
from openedx.core.lib.api.authentication import BearerAuthenticationAllowInactiveUser
|
||||
|
||||
|
||||
@@ -87,9 +88,9 @@ class ProgressTabView(RetrieveAPIView):
|
||||
'Pass' is not included.
|
||||
studio_url: (str) a str of the link to the grading in studio for the course
|
||||
verification_data: an object containing
|
||||
link: (str) the link to either start or retry verification
|
||||
status: (str) the status of the verification
|
||||
status_date: (str) the date time string of when the verification status was set
|
||||
link: (str) the link to either start or retry ID verification
|
||||
status: (str) the status of the ID verification
|
||||
status_date: (str) the date time string of when the ID verification status was set
|
||||
|
||||
**Returns**
|
||||
|
||||
@@ -128,7 +129,9 @@ class ProgressTabView(RetrieveAPIView):
|
||||
|
||||
course = get_course_with_access(request.user, 'load', course_key, check_if_enrolled=True)
|
||||
|
||||
enrollment_mode, _ = CourseEnrollment.enrollment_mode_for_user(request.user, course_key)
|
||||
course_overview = CourseOverview.get_from_id(course_key)
|
||||
enrollment = CourseEnrollment.get_enrollment(request.user, course_key)
|
||||
enrollment_mode = getattr(enrollment, 'mode', None)
|
||||
|
||||
# The block structure is used for both the course_grade and has_scheduled content fields
|
||||
# So it is called upfront and reused for optimization purposes
|
||||
@@ -184,6 +187,9 @@ class ProgressTabView(RetrieveAPIView):
|
||||
context = self.get_serializer_context()
|
||||
context['staff_access'] = bool(has_access(request.user, 'staff', course))
|
||||
context['course_key'] = course_key
|
||||
# course_overview and enrollment will be used by VerifiedModeSerializerMixin
|
||||
context['course_overview'] = course_overview
|
||||
context['enrollment'] = enrollment
|
||||
serializer = self.get_serializer_class()(data, context=context)
|
||||
|
||||
return Response(serializer.data)
|
||||
|
||||
Reference in New Issue
Block a user