diff --git a/common/djangoapps/student/models.py b/common/djangoapps/student/models.py index e1c4ff1123..b4a78d64d2 100644 --- a/common/djangoapps/student/models.py +++ b/common/djangoapps/student/models.py @@ -41,6 +41,7 @@ unenroll_done = django.dispatch.Signal(providing_args=["course_enrollment"]) log = logging.getLogger(__name__) AUDIT_LOG = logging.getLogger("audit") + class UserStanding(models.Model): """ This table contains a student's account's status. diff --git a/common/lib/symmath/symmath/formula.py b/common/lib/symmath/symmath/formula.py index d5b97a2550..b7c4dca2b4 100644 --- a/common/lib/symmath/symmath/formula.py +++ b/common/lib/symmath/symmath/formula.py @@ -14,6 +14,7 @@ import string # pylint: disable=W0402 import re import logging import operator +import requests import sympy from sympy.printing.latex import LatexPrinter from sympy.printing.str import StrPrinter @@ -25,11 +26,9 @@ from sympy.physics.quantum.state import * # import sympy.physics.quantum.qubit from xml.sax.saxutils import unescape -import sympy import unicodedata from lxml import etree #import subprocess -import requests from copy import deepcopy log = logging.getLogger(__name__) diff --git a/lms/djangoapps/courseware/tests/test_module_render.py b/lms/djangoapps/courseware/tests/test_module_render.py index a537e5c29a..abe07077cc 100644 --- a/lms/djangoapps/courseware/tests/test_module_render.py +++ b/lms/djangoapps/courseware/tests/test_module_render.py @@ -26,6 +26,9 @@ from .factories import UserFactory @override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE) class ModuleRenderTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase): + """ + Tests of courseware.module_render + """ def setUp(self): self.location = ['i4x', 'edX', 'toy', 'chapter', 'Overview'] self.course_id = 'edX/toy/2012_Fall' diff --git a/lms/djangoapps/django_comment_client/permissions.py b/lms/djangoapps/django_comment_client/permissions.py index b868d46e36..5cc4ff18df 100644 --- a/lms/djangoapps/django_comment_client/permissions.py +++ b/lms/djangoapps/django_comment_client/permissions.py @@ -1,7 +1,13 @@ +""" +Module for checking permissions with the comment_client backend +""" + import logging -from util.cache import cache from django.core import cache -cache = cache.get_cache('default') + + +CACHE = cache.get_cache('default') +CACHE_LIFESPAN = 60 def cached_has_permission(user, permission, course_id=None): @@ -9,12 +15,11 @@ def cached_has_permission(user, permission, course_id=None): Call has_permission if it's not cached. A change in a user's role or a role's permissions will only become effective after CACHE_LIFESPAN seconds. """ - CACHE_LIFESPAN = 60 key = "permission_%d_%s_%s" % (user.id, str(course_id), permission) - val = cache.get(key, None) + val = CACHE.get(key, None) if val not in [True, False]: val = has_permission(user, permission, course_id=course_id) - cache.set(key, val, CACHE_LIFESPAN) + CACHE.set(key, val, CACHE_LIFESPAN) return val @@ -72,31 +77,31 @@ def check_conditions_permissions(user, permissions, course_id, **kwargs): VIEW_PERMISSIONS = { - 'update_thread' : ['edit_content', ['update_thread', 'is_open', 'is_author']], - 'create_comment' : [["create_comment", "is_open"]], - 'delete_thread' : ['delete_thread', ['update_thread', 'is_author']], - 'update_comment' : ['edit_content', ['update_comment', 'is_open', 'is_author']], - 'endorse_comment' : ['endorse_comment'], - 'openclose_thread' : ['openclose_thread'], - 'create_sub_comment': [['create_sub_comment', 'is_open']], - 'delete_comment' : ['delete_comment', ['update_comment', 'is_open', 'is_author']], - 'vote_for_comment' : [['vote', 'is_open']], - 'undo_vote_for_comment': [['unvote', 'is_open']], - 'vote_for_thread' : [['vote', 'is_open']], - 'flag_abuse_for_thread': [['vote', 'is_open']], - 'un_flag_abuse_for_thread': [['vote', 'is_open']], - 'flag_abuse_for_comment': [['vote', 'is_open']], - 'un_flag_abuse_for_comment': [['vote', 'is_open']], - 'undo_vote_for_thread': [['unvote', 'is_open']], - 'pin_thread': ['create_comment'], - 'un_pin_thread': ['create_comment'], - 'follow_thread' : ['follow_thread'], - 'follow_commentable': ['follow_commentable'], - 'follow_user' : ['follow_user'], - 'unfollow_thread' : ['unfollow_thread'], - 'unfollow_commentable': ['unfollow_commentable'], - 'unfollow_user' : ['unfollow_user'], - 'create_thread' : ['create_thread'], + 'update_thread': ['edit_content', ['update_thread', 'is_open', 'is_author']], + 'create_comment': [["create_comment", "is_open"]], + 'delete_thread': ['delete_thread', ['update_thread', 'is_author']], + 'update_comment': ['edit_content', ['update_comment', 'is_open', 'is_author']], + 'endorse_comment': ['endorse_comment'], + 'openclose_thread': ['openclose_thread'], + 'create_sub_comment': [['create_sub_comment', 'is_open']], + 'delete_comment': ['delete_comment', ['update_comment', 'is_open', 'is_author']], + 'vote_for_comment': [['vote', 'is_open']], + 'undo_vote_for_comment': [['unvote', 'is_open']], + 'vote_for_thread': [['vote', 'is_open']], + 'flag_abuse_for_thread': [['vote', 'is_open']], + 'un_flag_abuse_for_thread': [['vote', 'is_open']], + 'flag_abuse_for_comment': [['vote', 'is_open']], + 'un_flag_abuse_for_comment': [['vote', 'is_open']], + 'undo_vote_for_thread': [['unvote', 'is_open']], + 'pin_thread': ['create_comment'], + 'un_pin_thread': ['create_comment'], + 'follow_thread': ['follow_thread'], + 'follow_commentable': ['follow_commentable'], + 'follow_user': ['follow_user'], + 'unfollow_thread': ['unfollow_thread'], + 'unfollow_commentable': ['unfollow_commentable'], + 'unfollow_user': ['unfollow_user'], + 'create_thread': ['create_thread'], 'update_moderator_status': ['manage_moderator'], } diff --git a/lms/lib/comment_client/models.py b/lms/lib/comment_client/models.py index 7296151c80..367b9abd10 100644 --- a/lms/lib/comment_client/models.py +++ b/lms/lib/comment_client/models.py @@ -1,4 +1,4 @@ -from .utils import * +from .utils import extract, perform_request, CommentClientRequestError class Model(object):