Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
13b9e58f
Commit
13b9e58f
authored
Aug 15, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #419 from MITx/feature/url_based_course_lists
URL based course lists
parents
213e3cdc
1c2b6e80
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
12 deletions
+67
-12
common/djangoapps/external_auth/views.py
+4
-3
common/djangoapps/student/views.py
+4
-3
lms/djangoapps/courseware/courses.py
+17
-4
lms/djangoapps/courseware/views.py
+4
-2
lms/envs/common.py
+6
-0
lms/envs/dev_int.py
+32
-0
No files found.
common/djangoapps/external_auth/views.py
View file @
13b9e58f
import
functools
import
json
import
logging
import
random
...
...
@@ -156,7 +157,7 @@ def edXauth_signup(request, eamap=None):
log
.
debug
(
'ExtAuth: doing signup for
%
s'
%
eamap
.
external_email
)
return
student_views
.
main_index
(
extra_context
=
context
)
return
student_views
.
main_index
(
request
,
extra_context
=
context
)
#-----------------------------------------------------------------------------
# MIT SSL
...
...
@@ -206,7 +207,7 @@ def edXauth_ssl_login(request):
pass
if
not
cert
:
# no certificate information - go onward to main index
return
student_views
.
main_index
()
return
student_views
.
main_index
(
request
)
(
user
,
email
,
fullname
)
=
ssl_dn_extract_info
(
cert
)
...
...
@@ -216,4 +217,4 @@ def edXauth_ssl_login(request):
credentials
=
cert
,
email
=
email
,
fullname
=
fullname
,
retfun
=
student_views
.
main_index
)
retfun
=
functools
.
partial
(
student_views
.
main_index
,
request
)
)
common/djangoapps/student/views.py
View file @
13b9e58f
...
...
@@ -68,9 +68,9 @@ def index(request):
from
external_auth.views
import
edXauth_ssl_login
return
edXauth_ssl_login
(
request
)
return
main_index
(
user
=
request
.
user
)
return
main_index
(
request
,
user
=
request
.
user
)
def
main_index
(
extra_context
=
{},
user
=
None
):
def
main_index
(
request
,
extra_context
=
{},
user
=
None
):
'''
Render the edX main page.
...
...
@@ -93,7 +93,8 @@ def main_index(extra_context = {}, user=None):
entry
.
summary
=
soup
.
getText
()
# The course selection work is done in courseware.courses.
universities
=
get_courses_by_university
(
None
)
universities
=
get_courses_by_university
(
None
,
domain
=
request
.
META
.
get
(
'HTTP_HOST'
))
context
=
{
'universities'
:
universities
,
'entries'
:
entries
}
context
.
update
(
extra_context
)
return
render_to_response
(
'index.html'
,
context
)
...
...
lms/djangoapps/courseware/courses.py
View file @
13b9e58f
...
...
@@ -2,8 +2,8 @@ from collections import defaultdict
from
fs.errors
import
ResourceNotFoundError
from
functools
import
wraps
import
logging
from
path
import
path
from
path
import
path
from
django.conf
import
settings
from
django.http
import
Http404
...
...
@@ -142,7 +142,8 @@ def get_course_info_section(course, section_key):
raise
KeyError
(
"Invalid about key "
+
str
(
section_key
))
def
get_courses_by_university
(
user
):
def
get_courses_by_university
(
user
,
domain
=
None
):
'''
Returns dict of lists of courses available, keyed by course.org (ie university).
Courses are sorted by course.number.
...
...
@@ -152,9 +153,21 @@ def get_courses_by_university(user):
courses
=
[
c
for
c
in
modulestore
()
.
get_courses
()
if
isinstance
(
c
,
CourseDescriptor
)]
courses
=
sorted
(
courses
,
key
=
lambda
course
:
course
.
number
)
if
domain
and
settings
.
MITX_FEATURES
.
get
(
'SUBDOMAIN_COURSE_LISTINGS'
):
subdomain
=
domain
.
split
(
"."
)[
0
]
if
subdomain
not
in
settings
.
COURSE_LISTINGS
:
subdomain
=
'default'
visible_courses
=
frozenset
(
settings
.
COURSE_LISTINGS
[
subdomain
])
else
:
visible_courses
=
frozenset
(
c
.
id
for
c
in
courses
)
universities
=
defaultdict
(
list
)
for
course
in
courses
:
if
has_access
(
user
,
course
,
'see_exists'
):
universities
[
course
.
org
]
.
append
(
course
)
if
not
has_access
(
user
,
course
,
'see_exists'
):
continue
if
course
.
id
not
in
visible_courses
:
continue
universities
[
course
.
org
]
.
append
(
course
)
return
universities
lms/djangoapps/courseware/views.py
View file @
13b9e58f
...
...
@@ -63,7 +63,8 @@ def courses(request):
'''
Render "find courses" page. The course selection work is done in courseware.courses.
'''
universities
=
get_courses_by_university
(
request
.
user
)
universities
=
get_courses_by_university
(
request
.
user
,
domain
=
request
.
META
.
get
(
'HTTP_HOST'
))
return
render_to_response
(
"courses.html"
,
{
'universities'
:
universities
})
...
...
@@ -246,7 +247,8 @@ def university_profile(request, org_id):
raise
Http404
(
"University Profile not found for {0}"
.
format
(
org_id
))
# Only grab courses for this org...
courses
=
get_courses_by_university
(
request
.
user
)[
org_id
]
courses
=
get_courses_by_university
(
request
.
user
,
domain
=
request
.
META
.
get
(
'HTTP_HOST'
))[
org_id
]
context
=
dict
(
courses
=
courses
,
org_id
=
org_id
)
template_file
=
"university_profile/{0}.html"
.
format
(
org_id
)
.
lower
()
...
...
lms/envs/common.py
View file @
13b9e58f
...
...
@@ -49,6 +49,11 @@ MITX_FEATURES = {
## Doing so will cause all courses to be released on production
'DISABLE_START_DATES'
:
False
,
# When True, all courses will be active, regardless of start date
# When True, will only publicly list courses by the subdomain. Expects you
# to define COURSE_LISTINGS, a dictionary mapping subdomains to lists of
# course_ids (see dev_int.py for an example)
'SUBDOMAIN_COURSE_LISTINGS'
:
False
,
'ENABLE_TEXTBOOK'
:
True
,
'ENABLE_DISCUSSION'
:
True
,
...
...
@@ -61,6 +66,7 @@ MITX_FEATURES = {
'ACCESS_REQUIRE_STAFF_FOR_COURSE'
:
False
,
'AUTH_USE_OPENID'
:
False
,
'AUTH_USE_MIT_CERTIFICATES'
:
False
,
}
# Used for A/B testing
...
...
lms/envs/dev_int.py
0 → 100644
View file @
13b9e58f
"""
This enables use of course listings by subdomain. To see it in action, point the
following domains to 127.0.0.1 in your /etc/hosts file:
berkeley.dev
harvard.dev
mit.dev
Note that OS X has a bug where using *.local domains is excruciatingly slow, so
use *.dev domains instead for local testing.
"""
from
.dev
import
*
MITX_FEATURES
[
'SUBDOMAIN_COURSE_LISTINGS'
]
=
True
COURSE_LISTINGS
=
{
'default'
:
[
'BerkeleyX/CS169.1x/2012_Fall'
,
'BerkeleyX/CS188.1x/2012_Fall'
,
'HarvardX/CS50x/2012'
,
'HarvardX/PH207x/2012_Fall'
,
'MITx/3.091x/2012_Fall'
,
'MITx/6.002x/2012_Fall'
,
'MITx/6.00x/2012_Fall'
],
'berkeley'
:
[
'BerkeleyX/CS169.1x/2012_Fall'
,
'BerkeleyX/CS188.1x/2012_Fall'
],
'harvard'
:
[
'HarvardX/CS50x/2012'
],
'mit'
:
[
'MITx/3.091x/2012_Fall'
,
'MITx/6.00x/2012_Fall'
]
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment