Commit 8ddd8c14 by Calen Pennington

Fix pylint/pep8 errors

parent da26ae25
...@@ -41,6 +41,7 @@ unenroll_done = django.dispatch.Signal(providing_args=["course_enrollment"]) ...@@ -41,6 +41,7 @@ unenroll_done = django.dispatch.Signal(providing_args=["course_enrollment"])
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
AUDIT_LOG = logging.getLogger("audit") AUDIT_LOG = logging.getLogger("audit")
class UserStanding(models.Model): class UserStanding(models.Model):
""" """
This table contains a student's account's status. This table contains a student's account's status.
......
...@@ -14,6 +14,7 @@ import string # pylint: disable=W0402 ...@@ -14,6 +14,7 @@ import string # pylint: disable=W0402
import re import re
import logging import logging
import operator import operator
import requests
import sympy import sympy
from sympy.printing.latex import LatexPrinter from sympy.printing.latex import LatexPrinter
from sympy.printing.str import StrPrinter from sympy.printing.str import StrPrinter
...@@ -25,11 +26,9 @@ from sympy.physics.quantum.state import * ...@@ -25,11 +26,9 @@ from sympy.physics.quantum.state import *
# import sympy.physics.quantum.qubit # import sympy.physics.quantum.qubit
from xml.sax.saxutils import unescape from xml.sax.saxutils import unescape
import sympy
import unicodedata import unicodedata
from lxml import etree from lxml import etree
#import subprocess #import subprocess
import requests
from copy import deepcopy from copy import deepcopy
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
......
...@@ -26,6 +26,9 @@ from .factories import UserFactory ...@@ -26,6 +26,9 @@ from .factories import UserFactory
@override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE) @override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE)
class ModuleRenderTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase): class ModuleRenderTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase):
"""
Tests of courseware.module_render
"""
def setUp(self): def setUp(self):
self.location = ['i4x', 'edX', 'toy', 'chapter', 'Overview'] self.location = ['i4x', 'edX', 'toy', 'chapter', 'Overview']
self.course_id = 'edX/toy/2012_Fall' self.course_id = 'edX/toy/2012_Fall'
......
"""
Module for checking permissions with the comment_client backend
"""
import logging import logging
from util.cache import cache
from django.core 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): def cached_has_permission(user, permission, course_id=None):
...@@ -9,12 +15,11 @@ 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 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. 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) 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]: if val not in [True, False]:
val = has_permission(user, permission, course_id=course_id) val = has_permission(user, permission, course_id=course_id)
cache.set(key, val, CACHE_LIFESPAN) CACHE.set(key, val, CACHE_LIFESPAN)
return val return val
...@@ -72,31 +77,31 @@ def check_conditions_permissions(user, permissions, course_id, **kwargs): ...@@ -72,31 +77,31 @@ def check_conditions_permissions(user, permissions, course_id, **kwargs):
VIEW_PERMISSIONS = { VIEW_PERMISSIONS = {
'update_thread' : ['edit_content', ['update_thread', 'is_open', 'is_author']], 'update_thread': ['edit_content', ['update_thread', 'is_open', 'is_author']],
'create_comment' : [["create_comment", "is_open"]], 'create_comment': [["create_comment", "is_open"]],
'delete_thread' : ['delete_thread', ['update_thread', 'is_author']], 'delete_thread': ['delete_thread', ['update_thread', 'is_author']],
'update_comment' : ['edit_content', ['update_comment', 'is_open', 'is_author']], 'update_comment': ['edit_content', ['update_comment', 'is_open', 'is_author']],
'endorse_comment' : ['endorse_comment'], 'endorse_comment': ['endorse_comment'],
'openclose_thread' : ['openclose_thread'], 'openclose_thread': ['openclose_thread'],
'create_sub_comment': [['create_sub_comment', 'is_open']], 'create_sub_comment': [['create_sub_comment', 'is_open']],
'delete_comment' : ['delete_comment', ['update_comment', 'is_open', 'is_author']], 'delete_comment': ['delete_comment', ['update_comment', 'is_open', 'is_author']],
'vote_for_comment' : [['vote', 'is_open']], 'vote_for_comment': [['vote', 'is_open']],
'undo_vote_for_comment': [['unvote', 'is_open']], 'undo_vote_for_comment': [['unvote', 'is_open']],
'vote_for_thread' : [['vote', 'is_open']], 'vote_for_thread': [['vote', 'is_open']],
'flag_abuse_for_thread': [['vote', 'is_open']], 'flag_abuse_for_thread': [['vote', 'is_open']],
'un_flag_abuse_for_thread': [['vote', 'is_open']], 'un_flag_abuse_for_thread': [['vote', 'is_open']],
'flag_abuse_for_comment': [['vote', 'is_open']], 'flag_abuse_for_comment': [['vote', 'is_open']],
'un_flag_abuse_for_comment': [['vote', 'is_open']], 'un_flag_abuse_for_comment': [['vote', 'is_open']],
'undo_vote_for_thread': [['unvote', 'is_open']], 'undo_vote_for_thread': [['unvote', 'is_open']],
'pin_thread': ['create_comment'], 'pin_thread': ['create_comment'],
'un_pin_thread': ['create_comment'], 'un_pin_thread': ['create_comment'],
'follow_thread' : ['follow_thread'], 'follow_thread': ['follow_thread'],
'follow_commentable': ['follow_commentable'], 'follow_commentable': ['follow_commentable'],
'follow_user' : ['follow_user'], 'follow_user': ['follow_user'],
'unfollow_thread' : ['unfollow_thread'], 'unfollow_thread': ['unfollow_thread'],
'unfollow_commentable': ['unfollow_commentable'], 'unfollow_commentable': ['unfollow_commentable'],
'unfollow_user' : ['unfollow_user'], 'unfollow_user': ['unfollow_user'],
'create_thread' : ['create_thread'], 'create_thread': ['create_thread'],
'update_moderator_status': ['manage_moderator'], 'update_moderator_status': ['manage_moderator'],
} }
......
from .utils import * from .utils import extract, perform_request, CommentClientRequestError
class Model(object): class Model(object):
......
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