From 5b7a59bc58864978760749a98790c71103132de9 Mon Sep 17 00:00:00 2001 From: Piotr Mitros Date: Fri, 13 Jan 2012 07:26:53 -0500 Subject: [PATCH] Staging page works --- auth/views.py | 18 +++++++------- courseware/views.py | 2 +- settings.py | 60 +++++++++++++++++++++++++-------------------- urls.py | 29 ++++++++++++---------- util/views.py | 2 +- 5 files changed, 61 insertions(+), 50 deletions(-) diff --git a/auth/views.py b/auth/views.py index 8a0af42062..fcb32c4e1a 100644 --- a/auth/views.py +++ b/auth/views.py @@ -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 diff --git a/courseware/views.py b/courseware/views.py index ad1c78bea4..03a7a05965 100644 --- a/courseware/views.py +++ b/courseware/views.py @@ -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 diff --git a/settings.py b/settings.py index 269f05edad..82e0bc1f88 100644 --- a/settings.py +++ b/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) diff --git a/urls.py b/urls.py index 6680c9f106..8f2738edd3 100644 --- a/urls.py +++ b/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[^/]*)/(?P[^/]*)/(?P
[^/]*)/$', 'courseware.views.index'), - url(r'^courseware/(?P[^/]*)/(?P[^/]*)/$', 'courseware.views.index'), - url(r'^courseware/(?P[^/]*)/$', 'courseware.views.index'), - url(r'^modx/(?P[^/]*)/(?P[^/]*)/(?P[^/]*)$', '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