Commit 8a893093 by Calen Pennington

Merge branch 'master' into asset-pipeline

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