Skip to content

Commit

Permalink
fix: made other course settings optional in serializers
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanDavidBuitrago committed Oct 8, 2024
1 parent 2fc55c1 commit 5381560
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lms/djangoapps/ccx/api/v0/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +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()
other_course_settings = serializers.JSONField(required=False, allow_null=True)

class Meta:
model = CustomCourseForEdX
Expand Down
7 changes: 2 additions & 5 deletions lms/djangoapps/ccx/api/v0/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,8 @@ def get_valid_input(request_data, ignore_missing=False):
field_errors['max_students_allowed'] = {'error_code': 'null_field_max_students_allowed'}

other_course_settings = request_data.get('other_course_settings')
if other_course_settings is not None:
if isinstance(other_course_settings, dict):
valid_input['other_course_settings'] = other_course_settings
else:
field_errors['other_course_settings'] = {'error_code': 'invalid_other_course_settings_type'}
if other_course_settings and isinstance(other_course_settings, dict):
valid_input['other_course_settings'] = other_course_settings

course_modules = request_data.get('course_modules')
if course_modules is not None:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.2.17 on 2024-10-07 10:53
# Generated by Django 3.2.17 on 2024-10-08 11:22

from django.db import migrations, models

Expand All @@ -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={}, null=True, verbose_name='Custom Json Content'),
),
]

0 comments on commit 5381560

Please sign in to comment.