Exemple #1
0
def _build_digest(user_content, user_info):
    """
    Transforms course/thread/item data from the comments service's response
    into a Digest for a single user.

    Results will only include threads/items from courses in which the user has
    been reported to be actively enrolled (by the user service).
    """
    return Digest(
        filter(lambda c: not c.empty, [
            _build_digest_course(course_id, course_dict,
                                 user_info["course_info"][course_id])
            for course_id, course_dict in user_content.iteritems()
            if course_id in user_info["course_info"]
        ]))
Exemple #2
0
 def _test_unicode_data(self,
                        input_text,
                        expected_text,
                        expected_html=None):
     user = {
         "id": "0",
         "username": "******",
     }
     digest = Digest([
         DigestCourse(TEST_COURSE_ID, [
             DigestThread("0", TEST_COURSE_ID, TEST_COMMENTABLE, input_text,
                          [DigestItem("test content", None, None)])
         ])
     ])
     (rendered_text, rendered_html) = render_digest(user, digest,
                                                    "Test Title",
                                                    "Test Description")
     self.assertIn(expected_text, rendered_text)
     self.assertIn(expected_html if expected_html else expected_text,
                   rendered_html)
Exemple #3
0
 def digest(user_id, user_dict):
     return Digest([
         Parser.course(course_id, course_dict)
         for course_id, course_dict in user_dict.iteritems()
     ])