Merge pull request #14901 from OmarIthawi/omar/commentable-id-unicode

Unicode fixes for django_comment_client and request_cached decorator
This commit is contained in:
Muzaffar yousaf
2017-05-04 15:07:22 +05:00
committed by GitHub
4 changed files with 31 additions and 5 deletions

View File

@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""Tests for django comment client views."""
from contextlib import contextmanager
import logging
@@ -1165,7 +1166,8 @@ class CreateThreadUnicodeTestCase(
request.user = self.student
request.view_name = "create_thread"
response = views.create_thread(
request, course_id=unicode(self.course.id), commentable_id="non_team_dummy_id"
# The commentable ID contains a username, the Unicode char below ensures it works fine
request, course_id=unicode(self.course.id), commentable_id=u"non_tåem_dummy_id"
)
self.assertEqual(response.status_code, 200)

View File

@@ -81,7 +81,7 @@ def _check_condition(user, condition, content):
try:
commentable_id = content['commentable_id']
request_cache_dict = RequestCache.get_request_cache().data
cache_key = "django_comment_client.check_team_member.{}.{}".format(user.id, commentable_id)
cache_key = u"django_comment_client.check_team_member.{}.{}".format(user.id, commentable_id)
if cache_key in request_cache_dict:
return request_cache_dict[cache_key]
team = get_team(commentable_id)