Commit 9f58673f by Clinton Blackburn

Updated CourseActivityByWeekSerializer

- Lower-casing activity type
- Converting active to any
parent dcf95bb4
......@@ -11,6 +11,19 @@ class CourseActivityByWeekSerializer(serializers.ModelSerializer):
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):
model = models.CourseActivityByWeek
fields = ('interval_start', 'interval_end', 'activity_type', 'count', 'course_id')
......
......@@ -43,11 +43,11 @@ class CourseActivityLastWeekTest(TestCaseWithAuthentication):
'course_id': 'edX/DemoX/Demo_Course',
'interval_start': datetime.datetime(2014, 5, 24, 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,
}
default.update(kwargs)
default['activity_type'] = default['activity_type'].upper()
default['activity_type'] = default['activity_type'].lower()
return default
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