Merge branch 'master' into asset-pipeline
Conflicts: static/js/application.js
This commit is contained in:
@@ -98,14 +98,20 @@ def render_x_module(user, request, xml_module, module_object_preload):
|
||||
|
||||
# get coursename if stored
|
||||
coursename = multicourse_settings.get_coursename_from_request(request)
|
||||
xp = multicourse_settings.get_course_xmlpath(coursename) # path to XML for the course
|
||||
|
||||
if coursename and settings.ENABLE_MULTICOURSE:
|
||||
xp = multicourse_settings.get_course_xmlpath(coursename) # path to XML for the course
|
||||
data_root = settings.DATA_DIR + xp
|
||||
else:
|
||||
data_root = settings.DATA_DIR
|
||||
|
||||
# Create a new instance
|
||||
ajax_url = settings.MITX_ROOT_URL + '/modx/'+module_type+'/'+module_id+'/'
|
||||
|
||||
system = I4xSystem(track_function = make_track_function(request),
|
||||
render_function = lambda x: render_module(user, request, x, module_object_preload),
|
||||
ajax_url = ajax_url,
|
||||
filestore = OSFS(settings.DATA_DIR + xp),
|
||||
filestore = OSFS(data_root),
|
||||
)
|
||||
instance=module_class(system,
|
||||
etree.tostring(xml_module),
|
||||
|
||||
@@ -19,7 +19,6 @@ from lxml import etree
|
||||
from module_render import render_module, make_track_function, I4xSystem
|
||||
from models import StudentModule
|
||||
from student.models import UserProfile
|
||||
from util.errors import record_exception
|
||||
from util.views import accepts
|
||||
from multicourse import multicourse_settings
|
||||
|
||||
@@ -114,7 +113,7 @@ def render_section(request, section):
|
||||
try:
|
||||
dom = content_parser.section_file(user, section, coursename)
|
||||
except:
|
||||
record_exception(log, "Unable to parse courseware xml")
|
||||
log.exception("Unable to parse courseware xml")
|
||||
return render_to_response('courseware-error.html', {})
|
||||
|
||||
context = {
|
||||
@@ -133,7 +132,7 @@ def render_section(request, section):
|
||||
try:
|
||||
module = render_module(user, request, dom, module_object_preload)
|
||||
except:
|
||||
record_exception(log, "Unable to load module")
|
||||
log.exception("Unable to load module")
|
||||
context.update({
|
||||
'init': '',
|
||||
'content': render_to_string("module-error.html", {}),
|
||||
@@ -182,7 +181,7 @@ def index(request, course=None, chapter="Using the System", section="Hints"):
|
||||
try:
|
||||
dom = content_parser.course_file(user,course) # also pass course to it, for course-specific XML path
|
||||
except:
|
||||
record_exception(log, "Unable to parse courseware xml")
|
||||
log.exception("Unable to parse courseware xml")
|
||||
return render_to_response('courseware-error.html', {})
|
||||
|
||||
dom_module = dom.xpath("//course[@name=$course]/chapter[@name=$chapter]//section[@name=$section]/*[1]",
|
||||
@@ -211,7 +210,7 @@ def index(request, course=None, chapter="Using the System", section="Hints"):
|
||||
try:
|
||||
module = render_module(user, request, module, module_object_preload)
|
||||
except:
|
||||
record_exception(log, "Unable to load module")
|
||||
log.exception("Unable to load module")
|
||||
context.update({
|
||||
'init': '',
|
||||
'content': render_to_string("module-error.html", {}),
|
||||
@@ -250,13 +249,18 @@ def modx_dispatch(request, module=None, dispatch=None, id=None):
|
||||
|
||||
# get coursename if stored
|
||||
coursename = multicourse_settings.get_coursename_from_request(request)
|
||||
xp = multicourse_settings.get_course_xmlpath(coursename) # path to XML for the course
|
||||
|
||||
if coursename and settings.ENABLE_MULTICOURSE:
|
||||
xp = multicourse_settings.get_course_xmlpath(coursename) # path to XML for the course
|
||||
data_root = settings.DATA_DIR + xp
|
||||
else:
|
||||
data_root = settings.DATA_DIR
|
||||
|
||||
# Grab the XML corresponding to the request from course.xml
|
||||
try:
|
||||
xml = content_parser.module_xml(request.user, module, 'id', id, coursename)
|
||||
except:
|
||||
record_exception(log, "Unable to load module during ajax call")
|
||||
log.exception("Unable to load module during ajax call")
|
||||
if accepts(request, 'text/html'):
|
||||
return render_to_response("module-error.html", {})
|
||||
else:
|
||||
@@ -267,7 +271,7 @@ def modx_dispatch(request, module=None, dispatch=None, id=None):
|
||||
system = I4xSystem(track_function = make_track_function(request),
|
||||
render_function = None,
|
||||
ajax_url = ajax_url,
|
||||
filestore = OSFS(settings.DATA_DIR + xp),
|
||||
filestore = OSFS(data_root),
|
||||
)
|
||||
|
||||
try:
|
||||
@@ -276,7 +280,7 @@ def modx_dispatch(request, module=None, dispatch=None, id=None):
|
||||
id,
|
||||
state=oldstate)
|
||||
except:
|
||||
record_exception(log, "Unable to load module instance during ajax call")
|
||||
log.exception("Unable to load module instance during ajax call")
|
||||
if accepts(request, 'text/html'):
|
||||
return render_to_response("module-error.html", {})
|
||||
else:
|
||||
|
||||
@@ -29,7 +29,7 @@ def get_logger_config(log_dir,
|
||||
" %(process)d] [%(filename)s:%(lineno)d] - %(message)s").format(
|
||||
logging_env=logging_env, hostname=hostname)
|
||||
|
||||
handlers = ['console'] if debug else ['console', 'syslogger']
|
||||
handlers = ['console'] if debug else ['console', 'syslogger', 'newrelic']
|
||||
|
||||
return {
|
||||
'version': 1,
|
||||
@@ -60,6 +60,11 @@ def get_logger_config(log_dir,
|
||||
'filename' : tracking_file_loc,
|
||||
'formatter' : 'raw',
|
||||
},
|
||||
'newrelic' : {
|
||||
'level': 'ERROR',
|
||||
'class': 'newrelic_logging.NewRelicHandler',
|
||||
'formatter': 'raw',
|
||||
}
|
||||
},
|
||||
'loggers' : {
|
||||
'django' : {
|
||||
|
||||
14
lib/newrelic_logging/__init__.py
Normal file
14
lib/newrelic_logging/__init__.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import newrelic.agent
|
||||
|
||||
import logging
|
||||
|
||||
class NewRelicHandler(logging.Handler):
|
||||
def emit(self, record):
|
||||
if record.exc_info is not None:
|
||||
params = record.__dict__
|
||||
params['log_message'] = record.getMessage()
|
||||
|
||||
newrelic.agent.record_exception(
|
||||
*record.exc_info,
|
||||
params=params
|
||||
)
|
||||
@@ -1,7 +0,0 @@
|
||||
import newrelic.agent
|
||||
import sys
|
||||
|
||||
def record_exception(logger, msg, params={}, ignore_errors=[]):
|
||||
logger.exception(msg)
|
||||
newrelic.agent.record_exception(*sys.exc_info())
|
||||
|
||||
@@ -10,6 +10,11 @@ class window.Calculator
|
||||
toggle: ->
|
||||
$('li.calc-main').toggleClass 'open'
|
||||
$('#calculator_wrapper #calculator_input').focus()
|
||||
if $('.calc.closed').length
|
||||
$('.calc').attr 'aria-label', 'Open Calculator'
|
||||
else
|
||||
$('.calc').attr 'aria-label', 'Close Calculator'
|
||||
|
||||
$('.calc').toggleClass 'closed'
|
||||
|
||||
helpToggle: ->
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<section class="main-content">
|
||||
<div class="course-wrapper">
|
||||
<section class="course-index">
|
||||
<section aria-label="Course Navigation" class="course-index">
|
||||
<header id="open_close_accordion">
|
||||
<h2>Courseware Index</h2>
|
||||
<a href="#">close</a>
|
||||
|
||||
@@ -27,14 +27,14 @@ $(document).ready(function(){
|
||||
<section class="updates">
|
||||
<%include file="updates.html" />
|
||||
</section>
|
||||
<section class="handouts">
|
||||
<section aria-label="Handout Navigation" class="handouts">
|
||||
<%include file="handouts.html" />
|
||||
</section>
|
||||
% else:
|
||||
<section class="updates">
|
||||
<%include file="guest_updates.html" />
|
||||
</section>
|
||||
<section class="handouts">
|
||||
<section aria-label="Handout Navigation" class="handouts">
|
||||
<%include file="guest_handouts.html" />
|
||||
</section>
|
||||
% endif
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<p> Copyright © 2012. MIT. <a href="/t/copyright.html">Some rights reserved.</a>
|
||||
</p>
|
||||
<nav>
|
||||
<ul class="social">
|
||||
<ul aria-label="Social Links" class="social">
|
||||
<li class="linkedin">
|
||||
<a href="http://www.linkedin.com/groups/Friends-Alumni-MITx-4316538">Linked In</a>
|
||||
</li>
|
||||
@@ -57,7 +57,7 @@
|
||||
<ul>
|
||||
<li><a href="#feedback_div" rel="leanModal">Feedback</a></li>
|
||||
<li class="calc-main">
|
||||
<a href="#" class="calc">Calculator</a>
|
||||
<a aria-label="Open Calculator" href="#" class="calc">Calculator</a>
|
||||
|
||||
<div id="calculator_wrapper">
|
||||
<form id="calculator">
|
||||
|
||||
@@ -97,7 +97,7 @@ function postJSON(url, data, callback) {
|
||||
<li><a href="/t/mitx_help.html">Help</a></li>
|
||||
</ul>
|
||||
|
||||
<ul class="social">
|
||||
<ul aria-label="Social Links" class="social">
|
||||
<li class="linkedin">
|
||||
<a href="http://www.linkedin.com/groups/Friends-Alumni-MITx-4316538">Linked In</a>
|
||||
</li>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<%page args="active_page" />
|
||||
<div class="header-wrapper">
|
||||
<header>
|
||||
<header aria-label="Global Navigation">
|
||||
<hgroup>
|
||||
<h1><em>
|
||||
% if settings.ENABLE_MULTICOURSE:
|
||||
|
||||
@@ -180,7 +180,7 @@ $(function() {
|
||||
|
||||
</section>
|
||||
|
||||
<section class="user-info">
|
||||
<section aria-label="Profile Navigation" class="user-info">
|
||||
|
||||
<header>
|
||||
<h1>Student Profile</h1>
|
||||
@@ -190,7 +190,7 @@ $(function() {
|
||||
<li>
|
||||
Name: <strong>${name}</strong>
|
||||
%if True:
|
||||
<a href="#apply_name_change" rel="leanModal" class="name-edit">Edit</a>
|
||||
<a href="#apply_name_change" rel="leanModal" class="name-edit" aria-label="Edit Name">Edit</a>
|
||||
%else:
|
||||
(Name change pending)
|
||||
%endif
|
||||
@@ -201,18 +201,18 @@ $(function() {
|
||||
</li>
|
||||
|
||||
<li>
|
||||
E-mail: <strong>${email}</strong> <a href="#change_email" rel="leanModal" class="edit-email">Edit</a>
|
||||
E-mail: <strong>${email}</strong> <a href="#change_email" rel="leanModal" class="edit-email" aria-label="Edit Email">Edit</a>
|
||||
</li>
|
||||
<li>
|
||||
Location: <div id="location_sub">${location}</div><div id="description"></div> <a href="#" id="change_location">Edit</a>
|
||||
Location: <div id="location_sub">${location}</div><div id="description"></div> <a href="#" id="change_location" aria-label="Edit Location">Edit</a>
|
||||
</li>
|
||||
<li>
|
||||
Language: <div id="language_sub">${language}</div> <a href="#" id="change_language">Edit</a>
|
||||
Language: <div id="language_sub">${language}</div> <a href="#" id="change_language" aria-label="Edit Language">Edit</a>
|
||||
</li>
|
||||
<li>
|
||||
Password reset
|
||||
<input id="id_email" type="hidden" name="email" maxlength="75" value="${email}" />
|
||||
<input type="submit" id="pwd_reset_button" value="Reset" />
|
||||
<input type="submit" id="pwd_reset_button" value="Reset" aria-label="Reset Password" />
|
||||
<p>We'll e-mail a password reset link to ${email}.</p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<nav class="sequence-nav">
|
||||
<nav aria-label="Section Navigation" class="sequence-nav">
|
||||
<ol>
|
||||
% for t in range(1,1+len(items)):
|
||||
<li><a href="#" class="seq_inactive" id="tt_${ t }"></a></li>
|
||||
@@ -14,7 +14,7 @@
|
||||
<div id="seq_content"></div>
|
||||
|
||||
<nav class="sequence-bottom">
|
||||
<ul>
|
||||
<ul aria-label="Section Navigation">
|
||||
<li class="${ id }prev prev"><a href="#">Previous</a></li>
|
||||
<li class="${ id }next next"><a href="#">Next</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
<section class="main-content">
|
||||
<div class="wiki-wrapper">
|
||||
<%block name="wiki_panel">
|
||||
<div id="wiki_panel">
|
||||
<div aria-label="Wiki Navigation" id="wiki_panel">
|
||||
<h2>Course Wiki</h2>
|
||||
<%
|
||||
if (wiki_article is not UNDEFINED):
|
||||
|
||||
@@ -59,7 +59,7 @@ $("#open_close_accordion a").click(function(){
|
||||
<section class="main-content">
|
||||
<div class="book-wrapper">
|
||||
|
||||
<section class="book-sidebar">
|
||||
<section aria-label="Textbook Navigation" class="book-sidebar">
|
||||
<header id="open_close_accordion">
|
||||
<h2>Table of Contents</h2>
|
||||
<a href="#">close</a>
|
||||
|
||||
Reference in New Issue
Block a user