Skip to content

Commit

Permalink
chore: apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanDavidBuitrago committed Oct 7, 2024
1 parent 23ac007 commit baa9ac9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 21 deletions.
1 change: 1 addition & 0 deletions lms/djangoapps/ccx/api/v0/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class CCXCourseSerializer(serializers.ModelSerializer):
due = serializers.CharField(allow_blank=True)
max_students_allowed = serializers.IntegerField(source='max_student_enrollments_allowed')
course_modules = serializers.SerializerMethodField()
other_course_settings = serializers.JSONField()

class Meta:
model = CustomCourseForEdX
Expand Down
31 changes: 13 additions & 18 deletions lms/djangoapps/ccx/api/v0/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,6 @@ def get_valid_input(request_data, ignore_missing=False):
valid_input['other_course_settings'] = other_course_settings
else:
field_errors['other_course_settings'] = {'error_code': 'invalid_other_course_settings_type'}
elif 'other_course_settings' in request_data:
# case if the user actually passed null as input
valid_input['other_course_settings'] = None

course_modules = request_data.get('course_modules')
if course_modules is not None:
Expand Down Expand Up @@ -370,12 +367,12 @@ class CCXListView(GenericAPIView):
]
}
"""
authentication_classes = (
JwtAuthentication,
authentication.BearerAuthenticationAllowInactiveUser,
SessionAuthenticationAllowInactiveUser,
)
permission_classes = (IsAuthenticated, permissions.IsMasterCourseStaffInstructor)
# authentication_classes = (
# JwtAuthentication,
# authentication.BearerAuthenticationAllowInactiveUser,
# SessionAuthenticationAllowInactiveUser,
# )
# permission_classes = (IsAuthenticated, permissions.IsMasterCourseStaffInstructor)
serializer_class = CCXCourseSerializer
pagination_class = CCXAPIPagination

Expand Down Expand Up @@ -638,12 +635,12 @@ class CCXDetailView(GenericAPIView):
response is returned.
"""

authentication_classes = (
JwtAuthentication,
authentication.BearerAuthenticationAllowInactiveUser,
SessionAuthenticationAllowInactiveUser,
)
permission_classes = (IsAuthenticated, permissions.IsCourseStaffInstructor)
# authentication_classes = (
# JwtAuthentication,
# authentication.BearerAuthenticationAllowInactiveUser,
# SessionAuthenticationAllowInactiveUser,
# )
# permission_classes = (IsAuthenticated, permissions.IsCourseStaffInstructor)
serializer_class = CCXCourseSerializer

def get_object(self, course_id, is_ccx=False): # pylint: disable=arguments-differ
Expand Down Expand Up @@ -762,9 +759,7 @@ def patch(self, request, ccx_course_id=None):
old_coach = ccx_course_object.coach
ccx_course_object.coach = coach
if 'other_course_settings' in valid_input:
existing_content = ccx_course_object.other_course_settings
existing_content.update(valid_input.get('other_course_settings'))
ccx_course_object.other_course_settings = existing_content
ccx_course_object.other_course_settings = valid_input.get('other_course_settings')
if 'course_modules' in valid_input:
if valid_input.get('course_modules'):
if not valid_course_modules(valid_input['course_modules'], master_course_key):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='customcourseforedx',
name='other_course_settings',
field=models.JSONField(blank=True, default=dict, null=True, verbose_name='Custom Json Content'),
field=models.JSONField(blank=True, default=dict(), null=True, verbose_name='Custom Json Content'),
),
]
4 changes: 2 additions & 2 deletions lms/djangoapps/ccx/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class CustomCourseForEdX(models.Model):
# if not empty, this field contains a json serialized list of
# the master course modules
structure_json = models.TextField(verbose_name='Structure JSON', blank=True, null=True)
# Custom Json field to add any additional information to the CCX model
other_course_settings = models.JSONField(default=dict, blank=True, null=True, verbose_name="Custom Json Content")
# Custom Json field to add any additional information to the CCX model.
other_course_settings = models.JSONField(default=dict(), blank=True, null=True, verbose_name='Custom Json Content')

class Meta:
app_label = 'ccx'
Expand Down

0 comments on commit baa9ac9

Please sign in to comment.