Commit 05cd3316 by Ned Batchelder

Fix pre-existing pylint errors. Diff-quality won't let me move the file otherwise.

parent 7c704f39
...@@ -45,13 +45,24 @@ def request_token(request): ...@@ -45,13 +45,24 @@ def request_token(request):
This token will be the same for all calls to `request_token` This token will be the same for all calls to `request_token`
made on the same request object. made on the same request object.
""" """
# pylint: disable=protected-access
if not hasattr(request, '_xblock_token'): if not hasattr(request, '_xblock_token'):
request._xblock_token = uuid.uuid1().get_hex() request._xblock_token = uuid.uuid1().get_hex()
return request._xblock_token return request._xblock_token
def wrap_xblock(runtime_class, block, view, frag, context, usage_id_serializer, request_token, display_name_only=False, extra_data=None): # pylint: disable=unused-argument def wrap_xblock(
runtime_class,
block,
view,
frag,
context, # pylint: disable=unused-argument
usage_id_serializer,
request_token, # pylint: disable=redefined-outer-name
display_name_only=False,
extra_data=None
):
""" """
Wraps the results of rendering an XBlock view in a standard <section> with identifying Wraps the results of rendering an XBlock view in a standard <section> with identifying
data so that the appropriate javascript module can be loaded onto it. data so that the appropriate javascript module can be loaded onto it.
...@@ -181,13 +192,14 @@ def grade_histogram(module_id): ...@@ -181,13 +192,14 @@ def grade_histogram(module_id):
from django.db import connection from django.db import connection
cursor = connection.cursor() cursor = connection.cursor()
q = """SELECT courseware_studentmodule.grade, query = """\
SELECT courseware_studentmodule.grade,
COUNT(courseware_studentmodule.student_id) COUNT(courseware_studentmodule.student_id)
FROM courseware_studentmodule FROM courseware_studentmodule
WHERE courseware_studentmodule.module_id=%s WHERE courseware_studentmodule.module_id=%s
GROUP BY courseware_studentmodule.grade""" GROUP BY courseware_studentmodule.grade"""
# Passing module_id this way prevents sql-injection. # Passing module_id this way prevents sql-injection.
cursor.execute(q, [module_id.to_deprecated_string()]) cursor.execute(query, [module_id.to_deprecated_string()])
grades = list(cursor.fetchall()) grades = list(cursor.fetchall())
grades.sort(key=lambda x: x[0]) # Add ORDER BY to sql query? grades.sort(key=lambda x: x[0]) # Add ORDER BY to sql query?
...@@ -218,7 +230,13 @@ def add_staff_markup(user, has_instructor_access, block, view, frag, context): ...@@ -218,7 +230,13 @@ def add_staff_markup(user, has_instructor_access, block, view, frag, context):
edit_link = "//" + settings.CMS_BASE + '/container/' + unicode(block.location) edit_link = "//" + settings.CMS_BASE + '/container/' + unicode(block.location)
# return edit link in rendered HTML for display # return edit link in rendered HTML for display
return wrap_fragment(frag, render_to_string("edit_unit_link.html", {'frag_content': frag.content, 'edit_link': edit_link})) return wrap_fragment(
frag,
render_to_string(
"edit_unit_link.html",
{'frag_content': frag.content, 'edit_link': edit_link}
)
)
else: else:
return frag return frag
...@@ -251,8 +269,9 @@ def add_staff_markup(user, has_instructor_access, block, view, frag, context): ...@@ -251,8 +269,9 @@ def add_staff_markup(user, has_instructor_access, block, view, frag, context):
source_file = block.source_file # source used to generate the problem XML, eg latex or word source_file = block.source_file # source used to generate the problem XML, eg latex or word
# useful to indicate to staff if problem has been released or not # Useful to indicate to staff if problem has been released or not.
# TODO (ichuang): use _has_access_descriptor.can_load in lms.courseware.access, instead of now>mstart comparison here # TODO (ichuang): use _has_access_descriptor.can_load in lms.courseware.access,
# instead of now>mstart comparison here.
now = datetime.datetime.now(UTC()) now = datetime.datetime.now(UTC())
is_released = "unknown" is_released = "unknown"
mstart = block.start mstart = block.start
...@@ -268,7 +287,8 @@ def add_staff_markup(user, has_instructor_access, block, view, frag, context): ...@@ -268,7 +287,8 @@ def add_staff_markup(user, has_instructor_access, block, view, frag, context):
log.warning("Unable to read field in Staff Debug information", exc_info=True) log.warning("Unable to read field in Staff Debug information", exc_info=True)
field_contents.append((name, "WARNING: Unable to read field")) field_contents.append((name, "WARNING: Unable to read field"))
staff_context = {'fields': field_contents, staff_context = {
'fields': field_contents,
'xml_attributes': getattr(block, 'xml_attributes', {}), 'xml_attributes': getattr(block, 'xml_attributes', {}),
'location': block.location, 'location': block.location,
'xqa_key': block.xqa_key, 'xqa_key': block.xqa_key,
...@@ -323,7 +343,7 @@ def get_course_update_items(course_updates, provided_index=0): ...@@ -323,7 +343,7 @@ def get_course_update_items(course_updates, provided_index=0):
# purely to handle free formed updates not done via editor. Actually kills them, but at least doesn't break. # purely to handle free formed updates not done via editor. Actually kills them, but at least doesn't break.
try: try:
course_html_parsed = html.fromstring(course_updates.data) course_html_parsed = html.fromstring(course_updates.data)
except (etree.XMLSyntaxError, etree.ParserError): except (etree.XMLSyntaxError, etree.ParserError): # pylint: disable=no-member
log.error("Cannot parse: " + course_updates.data) log.error("Cannot parse: " + course_updates.data)
escaped = escape(course_updates.data) escaped = escape(course_updates.data)
course_html_parsed = html.fromstring("<ol><li>" + escaped + "</li></ol>") course_html_parsed = html.fromstring("<ol><li>" + escaped + "</li></ol>")
......
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