feat: [AA-1207] remove redundant Tabs fields from courseware API (#30079)

feat: [AA-1207] remove redundant Tabs fields from courseware API

Remove redundant fields from courseware API.

- number
- verified_mode
- original_User_is_staff
- is_staff

This is the backend work for https://github.com/openedx/frontend-app-learning/pull/873
This commit is contained in:
Chris Deery
2022-03-18 12:09:52 -04:00
committed by GitHub
parent 7300072ce5
commit e8462bb667
3 changed files with 3 additions and 23 deletions

View File

@@ -2527,7 +2527,6 @@ paths:
as an object with the following fields:
* uri: The location of the image
* name: Name of the course
* number: Catalog number of the course
* offer: An object detailing upgrade discount information
* code: (str) Checkout code
* expiration_date: (str) Expiration of offer, in ISO 8601 notation
@@ -2535,7 +2534,6 @@ paths:
* discounted_price: (str) Upgrade price with checkout code; includes currency symbol
* percentage: (int) Amount of discount
* upgrade_url: (str) Checkout URL
* org: Name of the organization that owns the course
* related_programs: A list of objects that contains program data related to the given course including:
* progress: An object containing program progress:
* complete: (int) Number of complete courses in the program (a course is completed if the user has
@@ -2556,8 +2554,6 @@ paths:
* `"empty"`: no start date is specified
* pacing: Course pacing. Possible values: instructor, self
* user_timezone: User's chosen timezone setting (or null for browser default)
* is_staff: Whether the effective user has staff access to the course
* original_user_is_staff: Whether the original user has staff access to the course
* can_view_legacy_courseware: Indicates whether the user is able to see the legacy courseware view
* user_has_passing_grade: Whether or not the effective user's grade is equal to or above the courses minimum
passing grade

View File

@@ -93,9 +93,7 @@ class CourseInfoSerializer(serializers.Serializer): # pylint: disable=abstract-
license = serializers.CharField()
media = _CourseApiMediaCollectionSerializer(source='*')
name = serializers.CharField(source='display_name_with_default_escaped')
number = serializers.CharField(source='display_number_with_default')
offer = serializers.DictField()
org = serializers.CharField(source='display_org_with_default')
related_programs = CourseProgramSerializer(many=True)
short_description = serializers.CharField()
start = serializers.DateTimeField()
@@ -103,12 +101,9 @@ class CourseInfoSerializer(serializers.Serializer): # pylint: disable=abstract-
start_type = serializers.CharField()
pacing = serializers.CharField()
user_timezone = serializers.CharField()
verified_mode = serializers.DictField()
show_calculator = serializers.BooleanField()
original_user_is_staff = serializers.BooleanField()
can_view_legacy_courseware = serializers.BooleanField()
can_access_proctored_exams = serializers.BooleanField()
is_staff = serializers.BooleanField()
notes = serializers.DictField()
marketing_url = serializers.CharField()
celebrations = serializers.DictField()

View File

@@ -67,13 +67,13 @@ from common.djangoapps.student.models import (
)
from .serializers import CourseInfoSerializer
from .utils import serialize_upgrade_info
class CoursewareMeta:
"""
Encapsulates courseware and enrollment metadata.
"""
def __init__(self, course_key, request, username=''):
self.request = request
self.overview = course_detail(
@@ -82,17 +82,16 @@ class CoursewareMeta:
course_key,
)
self.original_user_is_staff = has_access(self.request.user, 'staff', self.overview).has_access
original_user_is_staff = has_access(self.request.user, 'staff', self.overview).has_access
self.original_user_is_global_staff = self.request.user.is_staff
self.course_key = course_key
self.course = get_course_by_id(self.course_key)
self.course_masquerade, self.effective_user = setup_masquerade(
self.request,
course_key,
staff_access=self.original_user_is_staff,
staff_access=original_user_is_staff,
)
self.request.user = self.effective_user
self.is_staff = has_access(self.effective_user, 'staff', self.overview).has_access
self.enrollment_object = CourseEnrollment.get_enrollment(self.effective_user, self.course_key,
select_related=['celebration', 'user__celebration'])
self.can_view_legacy_courseware = courseware_legacy_is_visible(
@@ -139,13 +138,6 @@ class CoursewareMeta:
def license(self):
return self.course.license
@property
def verified_mode(self):
"""
Return verified mode information, or None.
"""
return serialize_upgrade_info(self.effective_user, self.overview, self.enrollment_object)
@property
def notes(self):
"""
@@ -427,7 +419,6 @@ class CoursewareInformation(RetrieveAPIView):
as an object with the following fields:
* uri: The location of the image
* name: Name of the course
* number: Catalog number of the course
* offer: An object detailing upgrade discount information
* code: (str) Checkout code
* expiration_date: (str) Expiration of offer, in ISO 8601 notation
@@ -457,8 +448,6 @@ class CoursewareInformation(RetrieveAPIView):
* pacing: Course pacing. Possible values: instructor, self
* user_timezone: User's chosen timezone setting (or null for browser default)
* can_load_course: Whether the user can view the course (AccessResponse object)
* is_staff: Whether the effective user has staff access to the course
* original_user_is_staff: Whether the original user has staff access to the course
* can_view_legacy_courseware: Indicates whether the user is able to see the legacy courseware view
* user_has_passing_grade: Whether or not the effective user's grade is equal to or above the courses minimum
passing grade