Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #8 from edx-solutions/aamishbaloch/YONK-863
Browse files Browse the repository at this point in the history
YONK-863: Getting settings with no initial language issue fixed
  • Loading branch information
aamishbaloch committed Jan 19, 2018
2 parents 385ead6 + e4bca4b commit 0e33a3c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion course_metadata/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ class StringListField(serializers.ListField):

def to_representation(self, data):
"""
List of object instances -> List of dicts of primitive datatypes.
Parse a string into a python list. Converts empty string to empty list.
If data is already a list then no operation is performed on that data.
"""
if not data:
return []

if isinstance(data, basestring):
data = ast.literal_eval(data)
return data
Expand Down
8 changes: 8 additions & 0 deletions course_metadata/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ def setUp(self):
self.course_settings_uri = reverse('additional-course-settings', kwargs={'course_id': unicode(self.course.id)})
self.languages = ["it", "de-at", "es", "pt-br"]

def test_course_settings_get_with_no_initial_language(self):
"""
Test for getting settings with no initial language
"""
response = self.do_get(self.course_settings_uri)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.data['languages'], [])

def test_course_settings_languages(self):
"""
Test for setting/getting course languages from course settings
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name='course-edx-platform-extensions',
version='1.0.5',
version='1.0.6',
description='Course metadata management extension for edX platform',
long_description=open('README.rst').read(),
author='edX',
Expand Down

0 comments on commit 0e33a3c

Please sign in to comment.