Commit e92280ac by Chris Dodge Committed by Jonathan Piacenti

tunnel through any attributes needed for the overview API

remove duplicate data
parent 66985ff9
...@@ -107,5 +107,8 @@ TEST_COURSE_OVERVIEW_CONTENT = dedent( ...@@ -107,5 +107,8 @@ TEST_COURSE_OVERVIEW_CONTENT = dedent(
<section class="faq"> <section class="faq">
<p>Some text here</p> <p>Some text here</p>
</section> </section>
<section class="intro-video" data-videoid="foobar">
</section>
""" """
) )
...@@ -548,11 +548,12 @@ class CoursesApiTests(TestCase): ...@@ -548,11 +548,12 @@ class CoursesApiTests(TestCase):
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertGreater(len(response.data), 0) self.assertGreater(len(response.data), 0)
sections = response.data['sections'] sections = response.data['sections']
self.assertEqual(len(sections), 4) self.assertEqual(len(sections), 5)
self.assertIsNotNone(self._find_item_by_class(sections, 'about')) self.assertIsNotNone(self._find_item_by_class(sections, 'about'))
self.assertIsNotNone(self._find_item_by_class(sections, 'prerequisites')) self.assertIsNotNone(self._find_item_by_class(sections, 'prerequisites'))
self.assertIsNotNone(self._find_item_by_class(sections, 'course-staff')) self.assertIsNotNone(self._find_item_by_class(sections, 'course-staff'))
self.assertIsNotNone(self._find_item_by_class(sections, 'faq')) self.assertIsNotNone(self._find_item_by_class(sections, 'faq'))
self.assertIsNotNone(self._find_item_by_class(sections, 'intro-video'))
course_staff = self._find_item_by_class(sections, 'course-staff') course_staff = self._find_item_by_class(sections, 'course-staff')
staff = course_staff['articles'] staff = course_staff['articles']
...@@ -578,6 +579,10 @@ class CoursesApiTests(TestCase): ...@@ -578,6 +579,10 @@ class CoursesApiTests(TestCase):
invalid_tab = self._find_item_by_class(sections, 'invalid_tab') invalid_tab = self._find_item_by_class(sections, 'invalid_tab')
self.assertFalse(invalid_tab) self.assertFalse(invalid_tab)
intro_video = self._find_item_by_class(sections, 'intro-video')
self.assertEqual(len(intro_video['attributes']), 1)
self.assertEqual(intro_video['attributes']['data-videoid'], 'foobar')
def test_courses_overview_get_invalid_course(self): def test_courses_overview_get_invalid_course(self):
#try a bogus course_id to test failure case #try a bogus course_id to test failure case
test_uri = '{}/{}/overview'.format(self.base_courses_uri, self.test_bogus_course_id) test_uri = '{}/{}/overview'.format(self.base_courses_uri, self.test_bogus_course_id)
......
...@@ -173,6 +173,13 @@ def _parse_overview_html(html): ...@@ -173,6 +173,13 @@ def _parse_overview_html(html):
section_data = OrderedDict() section_data = OrderedDict()
section_data['class'] = section_class section_data['class'] = section_class
section_data['attributes'] = {}
for attribute_key in section.keys():
# don't return the class attribute as we are already using the class attribute
# as a key name to the result set, so we don't want to end up duplicating it
if attribute_key != 'class':
section_data['attributes'][attribute_key] = section.get(attribute_key)
articles = section.findall('article') articles = section.findall('article')
if articles: if articles:
section_data['articles'] = [] section_data['articles'] = []
...@@ -259,7 +266,7 @@ def _parse_updates_html(html): ...@@ -259,7 +266,7 @@ def _parse_updates_html(html):
class CourseContentList(SecureAPIView): class CourseContentList(SecureAPIView):
""" """
**Use Case** **Use Case**
CourseContentList gets a collection of content for a given CourseContentList gets a collection of content for a given
course. You can use the **uri** value in course. You can use the **uri** value in
...@@ -289,7 +296,7 @@ class CourseContentList(SecureAPIView): ...@@ -289,7 +296,7 @@ class CourseContentList(SecureAPIView):
**Response Values** **Response Values**
* category: The type of content. * category: The type of content.
* due: The due date. * due: The due date.
...@@ -328,7 +335,7 @@ class CourseContentList(SecureAPIView): ...@@ -328,7 +335,7 @@ class CourseContentList(SecureAPIView):
class CourseContentDetail(SecureAPIView): class CourseContentDetail(SecureAPIView):
""" """
**Use Case** **Use Case**
CourseContentDetail returns a JSON collection for a specified CourseContentDetail returns a JSON collection for a specified
CourseContent entity. If the specified CourseContent is the Course, the CourseContent entity. If the specified CourseContent is the Course, the
...@@ -422,7 +429,7 @@ class CourseContentDetail(SecureAPIView): ...@@ -422,7 +429,7 @@ class CourseContentDetail(SecureAPIView):
class CoursesList(SecureAPIView): class CoursesList(SecureAPIView):
""" """
**Use Case** **Use Case**
CoursesList returns a collection of courses in the edX Platform. You can CoursesList returns a collection of courses in the edX Platform. You can
use the uri value in the response to get details of the course. use the uri value in the response to get details of the course.
...@@ -464,7 +471,7 @@ class CoursesList(SecureAPIView): ...@@ -464,7 +471,7 @@ class CoursesList(SecureAPIView):
class CoursesDetail(SecureAPIView): class CoursesDetail(SecureAPIView):
""" """
**Use Case** **Use Case**
CoursesDetail returns details for a course. You can use the uri values CoursesDetail returns details for a course. You can use the uri values
in the resources collection in the response to get more course in the resources collection in the response to get more course
...@@ -506,7 +513,7 @@ class CoursesDetail(SecureAPIView): ...@@ -506,7 +513,7 @@ class CoursesDetail(SecureAPIView):
* id: The unique identifier for the course. * id: The unique identifier for the course.
* resources: A collection of URIs to use to get more information about * resources: A collection of URIs to use to get more information about
the course. the course.
""" """
def get(self, request, course_id): def get(self, request, course_id):
...@@ -556,7 +563,7 @@ class CoursesDetail(SecureAPIView): ...@@ -556,7 +563,7 @@ class CoursesDetail(SecureAPIView):
class CoursesGroupsList(SecureAPIView): class CoursesGroupsList(SecureAPIView):
""" """
**Use Case** **Use Case**
CoursesGroupsList returns a collection of course group relationship CoursesGroupsList returns a collection of course group relationship
entities(?) for a specified course entity. entities(?) for a specified course entity.
...@@ -697,7 +704,7 @@ class CoursesGroupsDetail(SecureAPIView): ...@@ -697,7 +704,7 @@ class CoursesGroupsDetail(SecureAPIView):
class CoursesOverview(SecureAPIView): class CoursesOverview(SecureAPIView):
""" """
**Use Case** **Use Case**
CoursesOverview returns an HTML representation of the overview for the CoursesOverview returns an HTML representation of the overview for the
specified course. CoursesOverview has an optional parse parameter that specified course. CoursesOverview has an optional parse parameter that
...@@ -742,7 +749,7 @@ class CoursesOverview(SecureAPIView): ...@@ -742,7 +749,7 @@ class CoursesOverview(SecureAPIView):
class CoursesUpdates(SecureAPIView): class CoursesUpdates(SecureAPIView):
""" """
**Use Case** **Use Case**
CoursesUpdates returns an HTML representation of the overview for the CoursesUpdates returns an HTML representation of the overview for the
specified course. CoursesUpdates has an optional parse parameter that specified course. CoursesUpdates has an optional parse parameter that
...@@ -785,7 +792,7 @@ class CoursesUpdates(SecureAPIView): ...@@ -785,7 +792,7 @@ class CoursesUpdates(SecureAPIView):
class CoursesStaticTabsList(SecureAPIView): class CoursesStaticTabsList(SecureAPIView):
""" """
**Use Case** **Use Case**
CoursesStaticTabsList returns a collection of custom pages in the CoursesStaticTabsList returns a collection of custom pages in the
course. CoursesStaticTabsList has an optional detail parameter that when course. CoursesStaticTabsList has an optional detail parameter that when
...@@ -837,10 +844,10 @@ class CoursesStaticTabsList(SecureAPIView): ...@@ -837,10 +844,10 @@ class CoursesStaticTabsList(SecureAPIView):
class CoursesStaticTabsDetail(SecureAPIView): class CoursesStaticTabsDetail(SecureAPIView):
""" """
**Use Case** **Use Case**
CoursesStaticTabsDetail returns a collection of custom pages in the CoursesStaticTabsDetail returns a collection of custom pages in the
course, including the page content. course, including the page content.
**Example Requests** **Example Requests**
...@@ -881,7 +888,7 @@ class CoursesStaticTabsDetail(SecureAPIView): ...@@ -881,7 +888,7 @@ class CoursesStaticTabsDetail(SecureAPIView):
class CoursesUsersList(SecureAPIView): class CoursesUsersList(SecureAPIView):
""" """
**Use Case** **Use Case**
CoursesUsersList returns a collection of users enrolled or pre-enrolled CoursesUsersList returns a collection of users enrolled or pre-enrolled
in the course. in the course.
...@@ -979,7 +986,7 @@ class CoursesUsersList(SecureAPIView): ...@@ -979,7 +986,7 @@ class CoursesUsersList(SecureAPIView):
class CoursesUsersDetail(SecureAPIView): class CoursesUsersDetail(SecureAPIView):
""" """
**Use Case** **Use Case**
CoursesUsersDetail returns a details about a specified user of a course. CoursesUsersDetail returns a details about a specified user of a course.
......
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