Commit a08838a2 by Matthew Mongeau

Namespace views, remove multicourse.

parent 4aab04e4
......@@ -78,7 +78,7 @@ def index(request):
for course in courses:
universities[course.org].append(course)
return render_to_response('index.html', {'universities': universities, 'entries': entries})
return render_to_response('student/index.html', {'universities': universities, 'entries': entries})
def course_from_id(id):
......@@ -108,7 +108,7 @@ def dashboard(request):
message = render_to_string('registration/activate_account_notice.html', {'email': user.email})
context = {'courses': courses, 'message': message}
return render_to_response('dashboard.html', context)
return render_to_response('student/dashboard.html', context)
def try_change_enrollment(request):
......@@ -512,14 +512,14 @@ def confirm_email_change(request, key):
try:
pec = PendingEmailChange.objects.get(activation_key=key)
except PendingEmailChange.DoesNotExist:
return render_to_response("invalid_email_key.html", {})
return render_to_response("registration/invalid_email_key.html", {})
user = pec.user
d = {'old_email': user.email,
'new_email': pec.new_email}
if len(User.objects.filter(email=pec.new_email)) != 0:
return render_to_response("email_exists.html", d)
return render_to_response("registration/email_exists.html", d)
subject = render_to_string('emails/email_change_subject.txt', d)
subject = ''.join(subject.splitlines())
......@@ -536,7 +536,7 @@ def confirm_email_change(request, key):
pec.delete()
user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL)
return render_to_response("email_change_successful.html", d)
return render_to_response("registration/email_change_successful.html", d)
@ensure_csrf_cookie
......@@ -573,7 +573,7 @@ def pending_name_changes(request):
'email':c.user.email,
'uid':c.user.id,
'cid':c.id} for c in changes]}
return render_to_response('name_changes.html', js)
return render_to_response('student/name_changes.html', js)
@ensure_csrf_cookie
......
......@@ -85,7 +85,7 @@ def certificate_request(request):
'survey_list': survey_list,
'name': user_info.name}
return render_to_response('cert_request.html', context)
return render_to_response('cert_request.html', context) # TODO: This doesn't exist currently
# This method should only be called if the user has a grade and has requested a certificate
......
......@@ -42,7 +42,7 @@ def edit_circuit(request, circuit):
if not circuit.isalnum():
raise Http404()
response = render_to_response('edit_circuit.html', {'name': circuit,
response = render_to_response('circuits/edit_circuit.html', {'name': circuit,
'circuit_line': circuit_line(circuit)})
response['Cache-Control'] = 'no-cache'
return response
......
......@@ -305,8 +305,8 @@ def add_histogram(module):
# TODO: fixme - no filename in module.xml in general (this code block for edx4edx)
# the following if block is for summer 2012 edX course development; it will change when the CMS comes online
if settings.MITX_FEATURES.get('DISPLAY_EDIT_LINK') and settings.DEBUG and module_xml.get('filename') is not None:
coursename = multicourse_settings.get_coursename_from_request(request)
github_url = multicourse_settings.get_course_github_url(coursename)
# coursename = multicourse_settings.get_coursename_from_request(request)
# github_url = multicourse_settings.get_course_github_url(coursename)
fn = module_xml.get('filename')
if module_xml.tag == 'problem': fn = 'problems/' + fn # grrr
edit_link = (github_url + '/tree/master/' + fn) if github_url is not None else None
......
......@@ -19,7 +19,6 @@ from django.views.decorators.cache import cache_control
from module_render import toc_for_course, get_module, get_section
from models import StudentModuleCache
from student.models import UserProfile
from multicourse import multicourse_settings
from util.cache import cache, cache_if_anonymous
from student.models import UserTestGroup, CourseEnrollment
......@@ -63,7 +62,7 @@ def courses(request):
for course in courses:
universities[course.org].append(course)
return render_to_response("courses.html", {'universities': universities})
return render_to_response("courseware/courses.html", {'universities': universities})
@cache_control(no_cache=True, no_store=True, must_revalidate=True)
......@@ -86,7 +85,7 @@ def gradebook(request, course_id):
'realname': UserProfile.objects.get(user=student).name
})
return render_to_response('gradebook.html', {'students': student_info, 'course': course})
return render_to_response('courseware/gradebook.html', {'students': student_info, 'course': course})
@login_required
......@@ -119,7 +118,7 @@ def profile(request, course_id, student_id=None):
}
context.update(grades.grade_sheet(student, course, student_module_cache))
return render_to_response('profile.html', context)
return render_to_response('courseware/profile.html', context)
def render_accordion(request, course, chapter, section):
......@@ -144,7 +143,7 @@ def render_accordion(request, course, chapter, section):
('course_id', course.id),
('format_url_params', format_url_params),
('csrf', csrf(request)['csrf_token'])] + template_imports.items())
return render_to_string('accordion.html', context)
return render_to_string('courseware/accordion.html', context)
@ensure_csrf_cookie
......@@ -180,9 +179,6 @@ def index(request, course_id, chapter=None, section=None,
chapter = clean(chapter)
section = clean(section)
if settings.ENABLE_MULTICOURSE:
settings.MODULESTORE['default']['OPTIONS']['data_dir'] = settings.DATA_DIR + multicourse_settings.get_course_xmlpath(course)
context = {
'csrf': csrf(request)['csrf_token'],
'accordion': render_accordion(request, course, chapter, section),
......@@ -201,7 +197,7 @@ def index(request, course_id, chapter=None, section=None,
module, _, _, _ = get_module(request.user, request, section.location, student_module_cache)
context['content'] = module.get_html()
result = render_to_response('courseware.html', context)
result = render_to_response('courseware/courseware.html', context)
return result
......@@ -220,7 +216,7 @@ def jump_to(request, probname=None):
'''
# get coursename if stored
coursename = multicourse_settings.get_coursename_from_request(request)
# coursename = multicourse_settings.get_coursename_from_request(request)
# begin by getting course.xml tree
xml = content_parser.course_file(request.user, coursename)
......@@ -257,7 +253,7 @@ def jump_to(request, probname=None):
def course_info(request, course_id):
course = check_course(course_id)
return render_to_response('info.html', {'course': course})
return render_to_response('courseware/info.html', {'course': course})
@ensure_csrf_cookie
......@@ -270,7 +266,7 @@ def course_about(request, course_id):
return False
course = check_course(course_id, course_must_be_open=False)
registered = registered_for_course(course, request.user)
return render_to_response('portal/course_about.html', {'course': course, 'registered': registered})
return render_to_response('courseware/course_about.html', {'course': course, 'registered': registered})
@ensure_csrf_cookie
......@@ -284,6 +280,6 @@ def university_profile(request, org_id):
# Only grab courses for this org...
courses = [c for c in all_courses if c.org == org_id]
context = dict(courses=courses, org_id=org_id)
template_file = "university_profile/{0}.html".format(org_id).lower()
template_file = "courseware/university_profile/{0}.html".format(org_id).lower()
return render_to_response(template_file, context)
# multicourse/multicourse_settings.py
#
# central module for providing fixed settings (course name, number, title)
# for multiple courses. Loads this information from django.conf.settings
#
# Allows backward compatibility with settings configurations without
# multiple courses specified.
#
# The central piece of configuration data is the dict COURSE_SETTINGS, with
# keys being the COURSE_NAME (spaces ok), and the value being a dict of
# parameter,value pairs. The required parameters are:
#
# - number : course number (used in the simplewiki pages)
# - title : humanized descriptive course title
#
# Optional parameters:
#
# - xmlpath : path (relative to data directory) for this course (defaults to "")
#
# If COURSE_SETTINGS does not exist, then fallback to 6.002_Spring_2012 default,
# for now.
from django.conf import settings
#-----------------------------------------------------------------------------
# load course settings
if hasattr(settings, 'COURSE_SETTINGS'): # in the future, this could be replaced by reading an XML file
COURSE_SETTINGS = settings.COURSE_SETTINGS
elif hasattr(settings, 'COURSE_NAME'): # backward compatibility
COURSE_SETTINGS = {settings.COURSE_NAME: {'number': settings.COURSE_NUMBER,
'title': settings.COURSE_TITLE,
'location': settings.COURSE_LOCATION,
},
}
else: # default to 6.002_Spring_2012
COURSE_SETTINGS = {'6.002_Spring_2012': {'number': '6.002x',
'title': 'Circuits and Electronics',
'location': 'i4x://edx/6002xs12/course/6.002 Spring 2012',
},
}
#-----------------------------------------------------------------------------
# wrapper functions around course settings
def get_coursename_from_request(request):
if 'coursename' in request.session:
coursename = request.session['coursename']
settings.COURSE_TITLE = get_course_title(coursename) # overwrite settings.COURSE_TITLE based on this
else: coursename = None
return coursename
def get_course_settings(coursename):
if not coursename:
if hasattr(settings, 'COURSE_DEFAULT'):
coursename = settings.COURSE_DEFAULT
else:
coursename = '6.002_Spring_2012'
if coursename in COURSE_SETTINGS:
return COURSE_SETTINGS[coursename]
coursename = coursename.replace(' ', '_')
if coursename in COURSE_SETTINGS:
return COURSE_SETTINGS[coursename]
return None
def is_valid_course(coursename):
return get_course_settings(coursename) != None
def get_course_property(coursename, property):
cs = get_course_settings(coursename)
# raise exception instead?
if not cs:
return ''
if property in cs:
return cs[property]
# default
return ''
def get_course_xmlpath(coursename):
return get_course_property(coursename, 'xmlpath')
def get_course_title(coursename):
return get_course_property(coursename, 'title')
def get_course_number(coursename):
return get_course_property(coursename, 'number')
def get_course_github_url(coursename):
return get_course_property(coursename, 'github_url')
def get_course_default_chapter(coursename):
return get_course_property(coursename, 'default_chapter')
def get_course_default_section(coursename):
return get_course_property(coursename, 'default_section')
def get_course_location(coursename):
return get_course_property(coursename, 'location')
from django.conf import settings
from mitxmako.shortcuts import render_to_response
from multicourse import multicourse_settings
def mitxhome(request):
''' Home page (link from main header). List of courses. '''
if settings.DEBUG:
print "[djangoapps.multicourse.mitxhome] MITX_ROOT_URL = " + settings.MITX_ROOT_URL
if settings.ENABLE_MULTICOURSE:
context = {'courseinfo': multicourse_settings.COURSE_SETTINGS}
return render_to_response("mitxhome.html", context)
return info(request)
......@@ -127,7 +127,6 @@ COURSE_TITLE = "Circuits and Electronics"
### Dark code. Should be enabled in local settings for devel.
ENABLE_MULTICOURSE = False # set to False to disable multicourse display (see lib.util.views.mitxhome)
QUICKEDIT = False
WIKI_ENABLED = False
......
......@@ -33,7 +33,6 @@ EDX4EDX_ROOT = ENV_ROOT / "data/edx4edx"
# ichuang
DEBUG = True
ENABLE_MULTICOURSE = True # set to False to disable multicourse display (see lib.util.views.mitxhome)
QUICKEDIT = True
MAKO_TEMPLATES['course'] = [DATA_DIR, EDX4EDX_ROOT ]
......
......@@ -34,7 +34,6 @@ EDX4EDX_ROOT = ENV_ROOT / "data/edx4edx"
# ichuang
DEBUG = True
ENABLE_MULTICOURSE = True # set to False to disable multicourse display (see lib.util.views.mitxhome)
QUICKEDIT = False
MAKO_TEMPLATES['course'] = [DATA_DIR, EDX4EDX_ROOT ]
......
......@@ -7,7 +7,6 @@ EDX4EDX_ROOT = ENV_ROOT / "data/edx4edx"
### Dark code. Should be enabled in local settings for devel.
QUICKEDIT = True
ENABLE_MULTICOURSE = True # set to False to disable multicourse display (see lib.util.views.mitxhome)
###
PIPELINE_CSS_COMPRESSOR = None
PIPELINE_JS_COMPRESSOR = None
......
......@@ -27,7 +27,6 @@ from lxml import etree
from courseware.module_render import make_track_function, I4xSystem, get_module
from courseware.models import StudentModule
from multicourse import multicourse_settings
from student.models import UserProfile
from util.cache import cache
from util.views import accepts
......@@ -50,7 +49,7 @@ def update_problem(pfn, pxml, coursename=None, overwrite=True, filestore=None):
'''
if not filestore:
if not coursename: coursename = DOGFOOD_COURSENAME
xp = multicourse_settings.get_course_xmlpath(coursename) # path to XML for the course
# xp = multicourse_settings.get_course_xmlpath(coursename) # path to XML for the course
pfn2 = settings.DATA_DIR + xp + 'problems/%s.xml' % pfn
fp = open(pfn2, 'w')
else:
......@@ -81,7 +80,7 @@ def df_capa_problem(request, id=None):
else:
coursename = request.session['coursename']
xp = multicourse_settings.get_course_xmlpath(coursename) # path to XML for the course
# xp = multicourse_settings.get_course_xmlpath(coursename) # path to XML for the course
# Grab the XML corresponding to the request from course.xml
module = 'problem'
......@@ -169,9 +168,9 @@ def quickedit(request, id=None, qetemplate='quickedit.html', coursename=None):
return quickedit_git_reload(request)
# get coursename if stored
if not coursename:
coursename = multicourse_settings.get_coursename_from_request(request)
xp = multicourse_settings.get_course_xmlpath(coursename) # path to XML for the course
# if not coursename:
# coursename = multicourse_settings.get_coursename_from_request(request)
# xp = multicourse_settings.get_course_xmlpath(coursename) # path to XML for the course
def get_lcp(coursename, id):
# Grab the XML corresponding to the request from course.xml
......@@ -301,8 +300,8 @@ def quickedit_git_reload(request):
return redirect('/')
# 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
# coursename = multicourse_settings.get_coursename_from_request(request)
# xp = multicourse_settings.get_course_xmlpath(coursename) # path to XML for the course
msg = ""
if 'cancel' in request.POST:
......
<%! from django.core.urlresolvers import reverse %>
<%namespace name='static' file='static_content.html'/>
<%namespace name='static' file='../static_content.html'/>
<footer>
<nav>
......
<%namespace name='static' file='static_content.html'/>
<%namespace name='static' file='../static_content.html'/>
<!DOCTYPE html>
<html>
<head>
......
......@@ -4,7 +4,7 @@
%>
<%namespace name='static' file='../static_content.html'/>
<%inherit file="../main.html" />
<%inherit file="../common/main.html" />
<%block name="js_extra">
% if not registered:
......
<%inherit file="main.html" />
<%inherit file="../common/main.html" />
<%namespace name='static' file='static_content.html'/>
<%namespace name='static' file='../static_content.html'/>
<%block name="title"><title>Courses</title></%block>
......@@ -22,17 +22,17 @@
<section class="courses">
<section class='university-column'>
%for course in universities['MITx']:
<%include file="course.html" args="course=course" />
<%include file="../common/course.html" args="course=course" />
%endfor
</section>
<section class='university-column'>
%for course in universities['HarvardX']:
<%include file="course.html" args="course=course" />
<%include file="../common/course.html" args="course=course" />
%endfor
</section>
<section class='university-column last'>
%for course in universities['BerkeleyX']:
<%include file="course.html" args="course=course" />
<%include file="../common/course.html" args="course=course" />
%endfor
</section>
</section>
......
<%inherit file="../main.html" />
<%inherit file="../common/main.html" />
<%namespace name='static' file='../static_content.html'/>
<section class="find-courses">
......
<%! from django.core.urlresolvers import reverse %>
<%inherit file="../main.html" />
<%inherit file="../common/main.html" />
<%namespace name='static' file='../static_content.html'/>
......
<%! from django.core.urlresolvers import reverse %>
<%inherit file="../main.html" />
<%inherit file="../common/main.html" />
<%namespace name='static' file='../static_content.html'/>
......
##This file is based on the template from the SimpleWiki source which carries the GPL license
<%inherit file="../main.html"/>
<%inherit file="../common/main.html"/>
<%namespace name='static' file='../static_content.html'/>
<%!
......
<%inherit file="../main.html" />
<%inherit file="../common/main.html" />
<%block name="title"><title>404</title></%block>
......
<%! from django.core.urlresolvers import reverse %>
<%namespace name='static' file='../static_content.html'/>
<%inherit file="../main.html" />
<%inherit file="../common/main.html" />
<%block name="title"><title>About edX</title></%block>
......
<%! from django.core.urlresolvers import reverse %>
<%namespace name='static' file='../static_content.html'/>
<%inherit file="../main.html" />
<%inherit file="../common/main.html" />
<%block name="title"><title>Contact edX</title></%block>
......
<%! from django.core.urlresolvers import reverse %>
<%inherit file="../main.html" />
<%inherit file="../common/main.html" />
<%namespace name='static' file='../static_content.html'/>
......
<%! from django.core.urlresolvers import reverse %>
<%namespace name='static' file='../static_content.html'/>
<%inherit file="../main.html" />
<%inherit file="../common/main.html" />
<%block name="title"><title>FAQ</title></%block>
......
<%! from django.core.urlresolvers import reverse %>
<%inherit file="../main.html" />
<%inherit file="../common/main.html" />
<%namespace name='static' file='../static_content.html'/>
......
<%inherit file="../main.html" />
<%inherit file="../common/main.html" />
<%! from django.core.urlresolvers import reverse %>
......
<%namespace name='static' file='../static_content.html'/>
<%inherit file="../main.html" />
<%inherit file="../common/main.html" />
<%block name="title"><title>Jobs</title></%block>
......
<%! from django.core.urlresolvers import reverse %>
<%namespace name='static' file='../static_content.html'/>
<%inherit file="../main.html" />
<%inherit file="../common/main.html" />
<%block name="title"><title>edX in the Press</title></%block>
......
<%! from django.core.urlresolvers import reverse %>
<%inherit file="../../main.html" />
<%inherit file="../../common/main.html" />
<%namespace name='static' file='../../static_content.html'/>
......
<%! from django.core.urlresolvers import reverse %>
<%inherit file="../../main.html" />
<%inherit file="../../common/main.html" />
<%namespace name='static' file='../../static_content.html'/>
......
<%! from django.core.urlresolvers import reverse %>
<%inherit file="../main.html" />
<%inherit file="../common/main.html" />
<%namespace name='static' file='../static_content.html'/>
......
<%inherit file="../main.html" />
<%inherit file="../common/main.html" />
<section class="outside-app">
<h1>Currently the <em>edX</em> servers are down</h1>
......
<%inherit file="../main.html" />
<%inherit file="../common/main.html" />
<section class="outside-app">
<h1>There has been a 500 error on the <em>edX</em> servers</h1>
......
<%inherit file="../main.html" />
<%inherit file="../common/main.html" />
<section class="outside-app">
<h1>Currently the <em>MITx</em> servers are overloaded</h1>
......
<%! from django.core.urlresolvers import reverse %>
<%inherit file="../main.html" />
<%inherit file="../common/main.html" />
<%namespace name='static' file='../static_content.html'/>
......
......@@ -2,9 +2,9 @@
from django.core.urlresolvers import reverse
from courseware.courses import course_image_url, get_course_about_section
%>
<%inherit file="main.html" />
<%inherit file="../common/main.html" />
<%namespace name='static' file='static_content.html'/>
<%namespace name='static' file='../static_content.html'/>
<%block name="title"><title>Dashboard</title></%block>
......
<%! from django.core.urlresolvers import reverse %>
<%! from time import strftime %>
<%inherit file="main.html" />
<%namespace name='static' file='static_content.html'/>
<%inherit file="../common/main.html" />
<%namespace name='static' file='../static_content.html'/>
<section class="home">
<header>
......@@ -79,17 +79,17 @@
<section class="courses">
<section class='university-column'>
%for course in universities['MITx']:
<%include file="course.html" args="course=course" />
<%include file="../common/course.html" args="course=course" />
%endfor
</section>
<section class='university-column'>
%for course in universities['HarvardX']:
<%include file="course.html" args="course=course" />
<%include file="../common/course.html" args="course=course" />
%endfor
</section>
<section class='university-column last'>
%for course in universities['BerkeleyX']:
<%include file="course.html" args="course=course" />
<%include file="../common/course.html" args="course=course" />
%endfor
</section>
</section>
......
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