Commit 3930dabd by Bridger Maxwell

Merge remote-tracking branch 'origin/master' into MITx/feature/bridger/fast_course_grading

parents 696804da 6abc2d73
Subproject commit 1c3381046c78e055439ba1c78e0df48410fcc13e Subproject commit e56ae380846f7c6cdaeacfc58880fab103540491
...@@ -83,7 +83,7 @@ TEMPLATE_CONTEXT_PROCESSORS = ( ...@@ -83,7 +83,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.request', 'django.core.context_processors.request',
'django.core.context_processors.static', 'django.core.context_processors.static',
'django.contrib.messages.context_processors.messages', 'django.contrib.messages.context_processors.messages',
'django.core.context_processors.auth', # this is required for admin 'django.contrib.auth.context_processors.auth', # this is required for admin
'django.core.context_processors.csrf', # necessary for csrf protection 'django.core.context_processors.csrf', # necessary for csrf protection
) )
...@@ -121,6 +121,7 @@ MIDDLEWARE_CLASSES = ( ...@@ -121,6 +121,7 @@ MIDDLEWARE_CLASSES = (
) )
############################ SIGNAL HANDLERS ################################ ############################ SIGNAL HANDLERS ################################
# This is imported to register the exception signal handling that logs exceptions
import monitoring.exceptions # noqa import monitoring.exceptions # noqa
############################ DJANGO_BUILTINS ################################ ############################ DJANGO_BUILTINS ################################
......
from django.conf import settings from django.conf import settings
from django.conf.urls.defaults import patterns, include, url from django.conf.urls import patterns, include, url
import django.contrib.auth.views import django.contrib.auth.views
......
...@@ -9,7 +9,7 @@ def expect_json(view_function): ...@@ -9,7 +9,7 @@ def expect_json(view_function):
if request.META['CONTENT_TYPE'] == "application/json": if request.META['CONTENT_TYPE'] == "application/json":
cloned_request = copy.copy(request) cloned_request = copy.copy(request)
cloned_request.POST = cloned_request.POST.copy() cloned_request.POST = cloned_request.POST.copy()
cloned_request.POST.update(json.loads(request.raw_post_data)) cloned_request.POST.update(json.loads(request.body))
return view_function(cloned_request, *args, **kwargs) return view_function(cloned_request, *args, **kwargs)
else: else:
return view_function(request, *args, **kwargs) return view_function(request, *args, **kwargs)
......
import logging
from django.conf import settings
from django.http import HttpResponseServerError
log = logging.getLogger("mitx")
class ExceptionLoggingMiddleware(object):
"""Just here to log unchecked exceptions that go all the way up the Django
stack"""
if not settings.TEMPLATE_DEBUG:
def process_exception(self, request, exception):
log.exception(exception)
return HttpResponseServerError("Server Error - Please try again later.")
...@@ -182,7 +182,7 @@ def get_courses_by_university(user): ...@@ -182,7 +182,7 @@ def get_courses_by_university(user):
courses = sorted(courses, key=lambda course: course.number) courses = sorted(courses, key=lambda course: course.number)
universities = defaultdict(list) universities = defaultdict(list)
for course in courses: for course in courses:
if settings.MITX_FEATURES.get('ENABLE_LMS_MIGRATION'): if settings.MITX_FEATURES.get('ACCESS_REQUIRE_STAFF_FOR_COURSE'):
if not has_access_to_course(user,course): if not has_access_to_course(user,course):
continue continue
universities[course.org].append(course) universities[course.org].append(course)
......
from django.conf.urls.defaults import * from django.conf.urls import *
urlpatterns = patterns('', urlpatterns = patterns('',
url(r'^$', 'heartbeat.views.heartbeat', name='heartbeat'), url(r'^$', 'heartbeat.views.heartbeat', name='heartbeat'),
......
from django.conf.urls.defaults import patterns, url from django.conf.urls import patterns, url
namespace_regex = r"[a-zA-Z\d._-]+" namespace_regex = r"[a-zA-Z\d._-]+"
article_slug = r'/(?P<article_path>' + namespace_regex + r'/[a-zA-Z\d_-]*)' article_slug = r'/(?P<article_path>' + namespace_regex + r'/[a-zA-Z\d_-]*)'
......
...@@ -2,12 +2,14 @@ from django.contrib.auth.decorators import login_required ...@@ -2,12 +2,14 @@ from django.contrib.auth.decorators import login_required
from mitxmako.shortcuts import render_to_response from mitxmako.shortcuts import render_to_response
from courseware.courses import check_course from courseware.courses import check_course
from lxml import etree
@login_required @login_required
def index(request, course_id, page=0): def index(request, course_id, page=0):
course = check_course(course_id) course = check_course(course_id)
return render_to_response('staticbook.html', {'page': int(page), 'course': course}) raw_table_of_contents = open('lms/templates/book_toc.xml', 'r') # TODO: This will need to come from S3
table_of_contents = etree.parse(raw_table_of_contents).getroot()
return render_to_response('staticbook.html', {'page': int(page), 'course': course, 'table_of_contents': table_of_contents})
def index_shifted(request, course_id, page): def index_shifted(request, course_id, page):
......
...@@ -109,7 +109,7 @@ TEMPLATE_CONTEXT_PROCESSORS = ( ...@@ -109,7 +109,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.messages.context_processors.messages', 'django.contrib.messages.context_processors.messages',
#'django.core.context_processors.i18n', #'django.core.context_processors.i18n',
'askbot.user_messages.context_processors.user_messages',#must be before auth 'askbot.user_messages.context_processors.user_messages',#must be before auth
'django.core.context_processors.auth', #this is required for admin 'django.contrib.auth.context_processors.auth', #this is required for admin
'django.core.context_processors.csrf', #necessary for csrf protection 'django.core.context_processors.csrf', #necessary for csrf protection
) )
...@@ -173,6 +173,9 @@ MODULESTORE = { ...@@ -173,6 +173,9 @@ MODULESTORE = {
} }
} }
############################ SIGNAL HANDLERS ################################
# This is imported to register the exception signal handling that logs exceptions
import monitoring.exceptions # noqa
############################### DJANGO BUILT-INS ############################### ############################### DJANGO BUILT-INS ###############################
# Change DEBUG/TEMPLATE_DEBUG in your environment settings files, not here # Change DEBUG/TEMPLATE_DEBUG in your environment settings files, not here
...@@ -285,7 +288,6 @@ TEMPLATE_LOADERS = ( ...@@ -285,7 +288,6 @@ TEMPLATE_LOADERS = (
) )
MIDDLEWARE_CLASSES = ( MIDDLEWARE_CLASSES = (
'util.middleware.ExceptionLoggingMiddleware',
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',
......
...@@ -16,3 +16,8 @@ MITX_FEATURES['ENABLE_TEXTBOOK'] = False ...@@ -16,3 +16,8 @@ MITX_FEATURES['ENABLE_TEXTBOOK'] = False
MITX_FEATURES['ENABLE_DISCUSSION'] = False MITX_FEATURES['ENABLE_DISCUSSION'] = False
MITX_FEATURES['ACCESS_REQUIRE_STAFF_FOR_COURSE'] = True # require that user be in the staff_* group to be able to enroll MITX_FEATURES['ACCESS_REQUIRE_STAFF_FOR_COURSE'] = True # require that user be in the staff_* group to be able to enroll
#-----------------------------------------------------------------------------
# disable django debug toolbars
INSTALLED_APPS = tuple([ app for app in INSTALLED_APPS if not app.startswith('debug_toolbar') ])
MIDDLEWARE_CLASSES = tuple([ mcl for mcl in MIDDLEWARE_CLASSES if not mcl.startswith('debug_toolbar') ])
...@@ -2,18 +2,14 @@ ${module_content} ...@@ -2,18 +2,14 @@ ${module_content}
%if edit_link: %if edit_link:
<div><a href="${edit_link}">Edit</a></div> <div><a href="${edit_link}">Edit</a></div>
% endif % endif
<div><a href="javascript:void(0)" onclick="javascript:$('#${element_id}_debug').slideToggle()">Staff Debug Info</a></div>
<script type="text/javascript">
$('#${element_id}_showhide').click(function(){$('#${element_id}_debug').toggle(); })
</script>
<div class="staff_info">
<input type="submit" id="${element_id}_showhide" value="Staff Debug Info"/>
<span style="display:none" id="${element_id}_debug"> <span style="display:none" id="${element_id}_debug">
<div class="staff_info">
definition = <pre>${definition | h}</pre> definition = <pre>${definition | h}</pre>
metadata = ${metadata | h} metadata = ${metadata | h}
</span>
</div> </div>
%if render_histogram: %if render_histogram:
<div id="histogram_${element_id}" class="histogram" data-histogram="${histogram}"></div> <div id="histogram_${element_id}" class="histogram" data-histogram="${histogram}"></div>
%endif %endif
</span>
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<%block name="headextra"> <%block name="headextra">
<%static:css group='course'/> <%static:css group='course'/>
<%static:js group='courseware'/>
</%block> </%block>
<%block name="js_extra"> <%block name="js_extra">
...@@ -71,7 +72,24 @@ $("#open_close_accordion a").click(function(){ ...@@ -71,7 +72,24 @@ $("#open_close_accordion a").click(function(){
</header> </header>
<ul id="booknav" class="treeview-booknav"> <ul id="booknav" class="treeview-booknav">
<%include file="book_toc.html" /> <%def name="print_entry(entry)">
<li>
<a href="javascript:goto_page(${entry.get('page')})">
${' '.join(entry.get(attribute, '') for attribute in ['chapter', 'name', 'page_label'])}
</a>
% if len(entry) > 0:
<ul>
% for child in entry:
${print_entry(child)}
% endfor
</ul>
% endif
</li>
</%def>
% for entry in table_of_contents:
${print_entry(entry)}
% endfor
</ul> </ul>
</section> </section>
......
from django.conf import settings from django.conf import settings
from django.conf.urls.defaults import patterns, include, url from django.conf.urls import patterns, include, url
from django.contrib import admin from django.contrib import admin
from django.conf.urls.static import static from django.conf.urls.static import static
......
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