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
d0f26418
Commit
d0f26418
authored
Aug 15, 2012
by
David Ormsbee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Account for the fact that sometimes we don't get HTTP_HOST (like for tests)
parent
7386d66c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
14 deletions
+12
-14
common/djangoapps/student/views.py
+1
-1
lms/djangoapps/courseware/courses.py
+9
-11
lms/djangoapps/courseware/views.py
+2
-2
No files found.
common/djangoapps/student/views.py
View file @
d0f26418
...
...
@@ -94,7 +94,7 @@ def main_index(request, extra_context={}, user=None):
# The course selection work is done in courseware.courses.
universities
=
get_courses_by_university
(
None
,
domain
=
request
.
META
[
'HTTP_HOST'
]
)
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 @
d0f26418
...
...
@@ -205,19 +205,18 @@ 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.
'''
subdomain
=
domain
.
split
(
"."
)[
0
]
# TODO: Clean up how 'error' is done.
# filter out any courses that errored.
if
settings
.
MITX_FEATURES
.
get
(
'SUBDOMAIN_COURSE_LISTINGS'
):
if
subdomain
in
settings
.
COURSE_LISTINGS
:
visible_courses
=
settings
.
COURSE_LISTINGS
[
subdomain
]
else
:
visible_courses
=
frozenset
(
settings
.
COURSE_LISTINGS
[
'default'
])
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
=
settings
.
COURSE_LISTINGS
.
get
(
domain
.
split
(
"."
)[
0
],
'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
:
<<<<<<<
HEAD
...
...
@@ -227,9 +226,8 @@ def get_courses_by_university(user, domain=None):
if
settings
.
MITX_FEATURES
.
get
(
'ACCESS_REQUIRE_STAFF_FOR_COURSE'
):
if
not
has_access_to_course
(
user
,
course
):
continue
if
settings
.
MITX_FEATURES
.
get
(
'SUBDOMAIN_COURSE_LISTINGS'
):
if
course
.
id
not
in
visible_courses
:
continue
if
course
.
id
not
in
visible_courses
:
continue
universities
[
course
.
org
]
.
append
(
course
)
>>>>>>>
implement
subdomain
-
based
course
displays
return
universities
...
...
lms/djangoapps/courseware/views.py
View file @
d0f26418
...
...
@@ -64,7 +64,7 @@ def courses(request):
Render "find courses" page. The course selection work is done in courseware.courses.
'''
universities
=
get_courses_by_university
(
request
.
user
,
domain
=
request
.
META
[
'HTTP_HOST'
]
)
domain
=
request
.
META
.
get
(
'HTTP_HOST'
)
)
return
render_to_response
(
"courses.html"
,
{
'universities'
:
universities
})
...
...
@@ -243,7 +243,7 @@ def university_profile(request, org_id):
# Only grab courses for this org...
courses
=
get_courses_by_university
(
request
.
user
,
domain
=
request
.
META
[
'HTTP_HOST'
]
)[
org_id
]
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
()
...
...
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