From e8462bb6677648fa2b988db5ecf14c594b38d464 Mon Sep 17 00:00:00 2001 From: Chris Deery <3932645+cdeery@users.noreply.github.com> Date: Fri, 18 Mar 2022 12:09:52 -0400 Subject: [PATCH] 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 --- docs/swagger.yaml | 4 ---- .../djangoapps/courseware_api/serializers.py | 5 ----- openedx/core/djangoapps/courseware_api/views.py | 17 +++-------------- 3 files changed, 3 insertions(+), 23 deletions(-) diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 148ac02010..48ca6e9ac6 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -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 diff --git a/openedx/core/djangoapps/courseware_api/serializers.py b/openedx/core/djangoapps/courseware_api/serializers.py index 1b86a84bd5..5682e12e61 100644 --- a/openedx/core/djangoapps/courseware_api/serializers.py +++ b/openedx/core/djangoapps/courseware_api/serializers.py @@ -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() diff --git a/openedx/core/djangoapps/courseware_api/views.py b/openedx/core/djangoapps/courseware_api/views.py index f4bc772cae..9e8c1b44bc 100644 --- a/openedx/core/djangoapps/courseware_api/views.py +++ b/openedx/core/djangoapps/courseware_api/views.py @@ -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