Commit 95547969 by Clinton Blackburn

Merge pull request #11 from edx/serializer-fix

Updated CourseActivityByWeekSerializer
parents f639f704 9f58673f
...@@ -11,6 +11,19 @@ class CourseActivityByWeekSerializer(serializers.ModelSerializer): ...@@ -11,6 +11,19 @@ class CourseActivityByWeekSerializer(serializers.ModelSerializer):
particular record is likely to change unexpectedly so we avoid exposing it. particular record is likely to change unexpectedly so we avoid exposing it.
""" """
activity_type = serializers.SerializerMethodField('get_activity_type')
def get_activity_type(self, obj):
"""
Lower-case activity type and change active to any.
"""
activity_type = obj.activity_type.lower()
if activity_type == 'active':
activity_type = 'any'
return activity_type
class Meta(object): class Meta(object):
model = models.CourseActivityByWeek model = models.CourseActivityByWeek
fields = ('interval_start', 'interval_end', 'activity_type', 'count', 'course_id') fields = ('interval_start', 'interval_end', 'activity_type', 'count', 'course_id')
......
...@@ -43,11 +43,11 @@ class CourseActivityLastWeekTest(TestCaseWithAuthentication): ...@@ -43,11 +43,11 @@ class CourseActivityLastWeekTest(TestCaseWithAuthentication):
'course_id': 'edX/DemoX/Demo_Course', 'course_id': 'edX/DemoX/Demo_Course',
'interval_start': datetime.datetime(2014, 5, 24, 0, 0, tzinfo=pytz.utc), 'interval_start': datetime.datetime(2014, 5, 24, 0, 0, tzinfo=pytz.utc),
'interval_end': datetime.datetime(2014, 6, 1, 0, 0, tzinfo=pytz.utc), 'interval_end': datetime.datetime(2014, 6, 1, 0, 0, tzinfo=pytz.utc),
'activity_type': 'ACTIVE', 'activity_type': 'any',
'count': 300, 'count': 300,
} }
default.update(kwargs) default.update(kwargs)
default['activity_type'] = default['activity_type'].upper() default['activity_type'] = default['activity_type'].lower()
return default return default
def test_activity_auth(self): def test_activity_auth(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment