Staging page works
This commit is contained in:
@@ -18,7 +18,7 @@ def csrf_token(context):
|
||||
|
||||
|
||||
def index(request):
|
||||
if request.user.is_authenticated():
|
||||
if settings.COURSEWARE_ENABLED and request.user.is_authenticated():
|
||||
return redirect('/courseware')
|
||||
else:
|
||||
csrf_token = csrf(request)['csrf_token']
|
||||
@@ -26,14 +26,14 @@ def index(request):
|
||||
return render_to_response('index.html', {'error' : '',
|
||||
'csrf': csrf_token })
|
||||
|
||||
def courseinfo(request):
|
||||
if request.user.is_authenticated():
|
||||
return redirect('/courseware')
|
||||
else:
|
||||
csrf_token = csrf(request)['csrf_token']
|
||||
# TODO: Clean up how 'error' is done.
|
||||
return render_to_response('courseinfo.html', {'error' : '',
|
||||
'csrf': csrf_token })
|
||||
# def courseinfo(request):
|
||||
# if request.user.is_authenticated():
|
||||
# return redirect('/courseware')
|
||||
# else:
|
||||
# csrf_token = csrf(request)['csrf_token']
|
||||
# # TODO: Clean up how 'error' is done.
|
||||
# return render_to_response('courseinfo.html', {'error' : '',
|
||||
# 'csrf': csrf_token })
|
||||
|
||||
def login_user(request, error=""):
|
||||
print request.POST
|
||||
|
||||
@@ -104,7 +104,7 @@ def render_accordion(request,course,chapter,section):
|
||||
def index(request, course="6.002 Spring 2012", chapter="Using the System", section="Hints"):
|
||||
''' Displays courseware accordion, and any associated content.
|
||||
'''
|
||||
if not request.user.is_authenticated():
|
||||
if not settings.COURSEWARE_ENABLED or not request.user.is_authenticated():
|
||||
return redirect('/')
|
||||
|
||||
# Fixes URLs -- we don't get funny encoding characters from spaces
|
||||
|
||||
60
settings.py
60
settings.py
@@ -1,4 +1,9 @@
|
||||
COURSEWARE_ENABLED = True
|
||||
ASKBOT_ENABLED = True
|
||||
if not COURSEWARE_ENABLED:
|
||||
ASKBOT_ENABLED = False
|
||||
|
||||
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
||||
|
||||
DEFAULT_FROM_EMAIL = 'pmitros@csail.mit.edu'
|
||||
DEFAULT_FEEDBACK_EMAIL = 'pmitros@csail.mit.edu'
|
||||
@@ -12,18 +17,12 @@ DEBUG = True
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
|
||||
ADMINS = (
|
||||
# ('Piotr Mitros', 'pmitros@csail.mit.edu'),
|
||||
('Piotr Mitros', 'pmitros@csail.mit.edu'),
|
||||
)
|
||||
|
||||
MANAGERS = ADMINS
|
||||
|
||||
# Local time zone for this installation. Choices can be found here:
|
||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
||||
# although not all choices may be available on all operating systems.
|
||||
# On Unix systems, a value of None will cause Django to use the same
|
||||
# timezone as the operating system.
|
||||
# If running in a Windows environment this must be set to the same as your
|
||||
# system time zone.
|
||||
TIME_ZONE = 'America/Chicago'
|
||||
|
||||
# Language code for this installation. All choices can be found here:
|
||||
@@ -40,17 +39,9 @@ USE_I18N = True
|
||||
# calendars according to the current locale
|
||||
USE_L10N = True
|
||||
|
||||
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
||||
# Example: "/home/media/media.lawrence.com/media/"
|
||||
MEDIA_ROOT = ''
|
||||
#MEDIA_ROOT = ''
|
||||
#MEDIA_URL = ''
|
||||
|
||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
||||
# trailing slash.
|
||||
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
|
||||
MEDIA_URL = ''
|
||||
|
||||
# URL prefix for static files.
|
||||
# Example: "http://media.lawrence.com/static/"
|
||||
STATIC_URL = '/static/'
|
||||
|
||||
# URL prefix for admin static files -- CSS, JavaScript and images.
|
||||
@@ -58,12 +49,6 @@ STATIC_URL = '/static/'
|
||||
# Examples: "http://foo.com/static/admin/", "/static/admin/".
|
||||
ADMIN_MEDIA_PREFIX = '/static/admin/'
|
||||
|
||||
# Additional locations of static files
|
||||
STATICFILES_DIRS = (
|
||||
# Put strings here, like "/home/html/static" or "C:/www/django/static".
|
||||
# Always use forward slashes, even on Windows.
|
||||
# Don't forget to use absolute paths, not relative paths.
|
||||
)
|
||||
|
||||
# List of finder classes that know how to find static files in
|
||||
# various locations.
|
||||
@@ -115,8 +100,6 @@ INSTALLED_APPS = (
|
||||
# 'django.contrib.admindocs',
|
||||
)
|
||||
|
||||
#EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
||||
|
||||
# A sample logging configuration. The only tangible logging
|
||||
# performed by this configuration is to send an email to
|
||||
# the site admins on every HTTP 500 error.
|
||||
@@ -142,9 +125,34 @@ LOGGING = {
|
||||
|
||||
TRACK_DIR = None
|
||||
|
||||
# Django settings for mitx project.
|
||||
execfile("../settings.py")
|
||||
|
||||
if 'TRACK_DIR' not in locals():
|
||||
TRACK_DIR = BASE_DIR+'/track_dir/'
|
||||
if 'ASKBOT_EXTRA_SKINS_DIR' not in locals():
|
||||
ASKBOT_EXTRA_SKINS_DIR = BASE_DIR+'/askbot/skins'
|
||||
if 'ASKBOT_DIR' not in locals():
|
||||
ASKBOT_DIR = BASE_DIR
|
||||
if 'STATIC_ROOT' not in locals():
|
||||
STATIC_ROOT = BASE_DIR+'/staticroot/'
|
||||
if 'DATA_DIR' not in locals():
|
||||
DATA_DIR = BASE_DIR+'/data/'
|
||||
if 'TEXTBOOK_DIR' not in locals():
|
||||
TEXTBOOK_DIR = BASE_DIR+'/textbook/'
|
||||
|
||||
if 'TEMPLATE_DIRS' not in locals():
|
||||
TEMPLATE_DIRS = (
|
||||
BASE_DIR+'/templates/',
|
||||
DATA_DIR+'/templates',
|
||||
TEXTBOOK_DIR,
|
||||
)
|
||||
|
||||
if 'STATICFILES_DIRS' not in locals():
|
||||
STATICFILES_DIRS = (
|
||||
BASE_DIR+'/3rdParty/static',
|
||||
BASE_DIR+'/static'
|
||||
)
|
||||
|
||||
if ASKBOT_ENABLED:
|
||||
import sys
|
||||
sys.path.append(ASKBOT_DIR)
|
||||
|
||||
29
urls.py
29
urls.py
@@ -9,25 +9,13 @@ from django.contrib import admin
|
||||
|
||||
urlpatterns = ('',
|
||||
url(r'^event$', 'track.views.user_track'),
|
||||
(r'^wiki/', include('simplewiki.urls')),
|
||||
url(r'^courseware/(?P<course>[^/]*)/(?P<chapter>[^/]*)/(?P<section>[^/]*)/$', 'courseware.views.index'),
|
||||
url(r'^courseware/(?P<course>[^/]*)/(?P<chapter>[^/]*)/$', 'courseware.views.index'),
|
||||
url(r'^courseware/(?P<course>[^/]*)/$', 'courseware.views.index'),
|
||||
url(r'^modx/(?P<module>[^/]*)/(?P<id>[^/]*)/(?P<dispatch>[^/]*)$', 'courseware.views.modx_dispatch'), #reset_problem'),
|
||||
url(r'^courseware/$', 'courseware.views.index'),
|
||||
url(r'^profile$', 'courseware.views.profile'),
|
||||
url(r'^change_setting$', 'auth.views.change_setting'),
|
||||
url(r'^t/(?P<template>[^/]*)$', 'static_template_view.views.index'),
|
||||
url(r'^s/(?P<template>[^/]*)$', 'static_template_view.views.auth_index'),
|
||||
url(r'^book/(?P<page>[^/]*)$', 'staticbook.views.index'),
|
||||
url(r'^book*$', 'staticbook.views.index'),
|
||||
url(r'^logout$', 'auth.views.logout_user'),
|
||||
url(r'^login$', 'auth.views.login_user'),
|
||||
url(r'^login/(?P<error>[^/]*)$', 'auth.views.login_user'),
|
||||
url(r'^create_account$', 'auth.views.create_account'),
|
||||
url(r'^activate/(?P<key>[^/]*)$', 'auth.views.activate_account'),
|
||||
url(r'^$', 'auth.views.index'),
|
||||
url(r'^course_info/$', 'auth.views.courseinfo'),
|
||||
url(r'^password_reset/$', 'django.contrib.auth.views.password_reset',
|
||||
dict(from_email='6002-admin@mit.edu'),name='auth_password_reset'),
|
||||
url(r'^password_change/$',django.contrib.auth.views.password_change,name='auth_password_change'),
|
||||
@@ -38,11 +26,26 @@ urlpatterns = ('',
|
||||
name='auth_password_reset_complete'),
|
||||
url(r'^password_reset_done/$',django.contrib.auth.views.password_reset_done,
|
||||
name='auth_password_reset_done'),
|
||||
url(r'^send_feedback$', 'util.views.send_feedback'),
|
||||
url(r'^courseware/$', 'courseware.views.index'),
|
||||
)
|
||||
|
||||
if settings.COURSEWARE_ENABLED:
|
||||
urlpatterns=urlpatterns + (url(r'^wiki/', include('simplewiki.urls')),
|
||||
url(r'^courseware/(?P<course>[^/]*)/(?P<chapter>[^/]*)/(?P<section>[^/]*)/$', 'courseware.views.index'),
|
||||
url(r'^courseware/(?P<course>[^/]*)/(?P<chapter>[^/]*)/$', 'courseware.views.index'),
|
||||
url(r'^courseware/(?P<course>[^/]*)/$', 'courseware.views.index'),
|
||||
url(r'^modx/(?P<module>[^/]*)/(?P<id>[^/]*)/(?P<dispatch>[^/]*)$', 'courseware.views.modx_dispatch'), #reset_problem'),
|
||||
url(r'^profile$', 'courseware.views.profile'),
|
||||
url(r'^change_setting$', 'auth.views.change_setting'),
|
||||
url(r'^s/(?P<template>[^/]*)$', 'static_template_view.views.auth_index'),
|
||||
url(r'^book/(?P<page>[^/]*)$', 'staticbook.views.index'),
|
||||
url(r'^book*$', 'staticbook.views.index'),
|
||||
# url(r'^course_info/$', 'auth.views.courseinfo'),
|
||||
# url(r'^show_circuit/(?P<circuit>[^/]*)$', 'circuit.views.show_circuit'),
|
||||
url(r'^edit_circuit/(?P<circuit>[^/]*)$', 'circuit.views.edit_circuit'),
|
||||
url(r'^save_circuit/(?P<circuit>[^/]*)$', 'circuit.views.save_circuit'),
|
||||
url(r'^calculate$', 'util.views.calculate'),
|
||||
url(r'^send_feedback$', 'util.views.send_feedback'),
|
||||
)
|
||||
|
||||
if settings.ASKBOT_ENABLED:
|
||||
|
||||
@@ -16,7 +16,7 @@ def calculate(request):
|
||||
raise Http404
|
||||
equation = request.GET['equation']
|
||||
try:
|
||||
result = courseware.calc.evaluator({}, {}, equation)
|
||||
result = courseware.capa.calc.evaluator({}, {}, equation)
|
||||
except:
|
||||
return HttpResponse(json.dumps({'result':'Invalid syntax'}))
|
||||
return HttpResponse(json.dumps({'result':result}))
|
||||
|
||||
Reference in New Issue
Block a user