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
18822bdb
Commit
18822bdb
authored
Oct 05, 2014
by
John Eskew
Committed by
Don Mitchell
Oct 06, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wrap course info and dashboard in bulk ops wrapper to reduce Mongo calls.
parent
0ed4ee32
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
47 deletions
+50
-47
common/djangoapps/student/views.py
+19
-17
lms/djangoapps/courseware/views.py
+31
-30
No files found.
common/djangoapps/student/views.py
View file @
18822bdb
...
...
@@ -246,23 +246,25 @@ def get_course_enrollment_pairs(user, course_org_filter, org_filter_out_set):
a student's dashboard.
"""
for
enrollment
in
CourseEnrollment
.
enrollments_for_user
(
user
):
course
=
modulestore
()
.
get_course
(
enrollment
.
course_id
)
if
course
and
not
isinstance
(
course
,
ErrorDescriptor
):
# if we are in a Microsite, then filter out anything that is not
# attributed (by ORG) to that Microsite
if
course_org_filter
and
course_org_filter
!=
course
.
location
.
org
:
continue
# Conversely, if we are not in a Microsite, then let's filter out any enrollments
# with courses attributed (by ORG) to Microsites
elif
course
.
location
.
org
in
org_filter_out_set
:
continue
yield
(
course
,
enrollment
)
else
:
log
.
error
(
"User {0} enrolled in {2} course {1}"
.
format
(
user
.
username
,
enrollment
.
course_id
,
"broken"
if
course
else
"non-existent"
))
store
=
modulestore
()
with
store
.
bulk_operations
(
enrollment
.
course_id
):
course
=
store
.
get_course
(
enrollment
.
course_id
)
if
course
and
not
isinstance
(
course
,
ErrorDescriptor
):
# if we are in a Microsite, then filter out anything that is not
# attributed (by ORG) to that Microsite
if
course_org_filter
and
course_org_filter
!=
course
.
location
.
org
:
continue
# Conversely, if we are not in a Microsite, then let's filter out any enrollments
# with courses attributed (by ORG) to Microsites
elif
course
.
location
.
org
in
org_filter_out_set
:
continue
yield
(
course
,
enrollment
)
else
:
log
.
error
(
"User {0} enrolled in {2} course {1}"
.
format
(
user
.
username
,
enrollment
.
course_id
,
"broken"
if
course
else
"non-existent"
))
def
_cert_info
(
user
,
course
,
cert_status
):
...
...
lms/djangoapps/courseware/views.py
View file @
18822bdb
...
...
@@ -559,41 +559,42 @@ def course_info(request, course_id):
course_key
=
SlashSeparatedCourseKey
.
from_deprecated_string
(
course_id
)
course
=
get_course_with_access
(
request
.
user
,
'load'
,
course_key
)
staff_access
=
has_access
(
request
.
user
,
'staff'
,
course
)
masq
=
setup_masquerade
(
request
,
staff_access
)
# allow staff to toggle masquerade on info page
reverifications
=
fetch_reverify_banner_info
(
request
,
course_key
)
studio_url
=
get_studio_url
(
course
,
'course_info'
)
with
modulestore
()
.
bulk_operations
(
course_key
):
course
=
get_course_with_access
(
request
.
user
,
'load'
,
course_key
)
staff_access
=
has_access
(
request
.
user
,
'staff'
,
course
)
masq
=
setup_masquerade
(
request
,
staff_access
)
# allow staff to toggle masquerade on info page
reverifications
=
fetch_reverify_banner_info
(
request
,
course_key
)
studio_url
=
get_studio_url
(
course
,
'course_info'
)
# link to where the student should go to enroll in the course:
# about page if there is not marketing site, SITE_NAME if there is
url_to_enroll
=
reverse
(
course_about
,
args
=
[
course_id
])
if
settings
.
FEATURES
.
get
(
'ENABLE_MKTG_SITE'
):
url_to_enroll
=
marketing_link
(
'COURSES'
)
# link to where the student should go to enroll in the course:
# about page if there is not marketing site, SITE_NAME if there is
url_to_enroll
=
reverse
(
course_about
,
args
=
[
course_id
])
if
settings
.
FEATURES
.
get
(
'ENABLE_MKTG_SITE'
):
url_to_enroll
=
marketing_link
(
'COURSES'
)
show_enroll_banner
=
request
.
user
.
is_authenticated
()
and
not
CourseEnrollment
.
is_enrolled
(
request
.
user
,
course
.
id
)
show_enroll_banner
=
request
.
user
.
is_authenticated
()
and
not
CourseEnrollment
.
is_enrolled
(
request
.
user
,
course
.
id
)
context
=
{
'request'
:
request
,
'course_id'
:
course_key
.
to_deprecated_string
(),
'cache'
:
None
,
'course'
:
course
,
'staff_access'
:
staff_access
,
'masquerade'
:
masq
,
'studio_url'
:
studio_url
,
'reverifications'
:
reverifications
,
'show_enroll_banner'
:
show_enroll_banner
,
'url_to_enroll'
:
url_to_enroll
,
}
context
=
{
'request'
:
request
,
'course_id'
:
course_key
.
to_deprecated_string
(),
'cache'
:
None
,
'course'
:
course
,
'staff_access'
:
staff_access
,
'masquerade'
:
masq
,
'studio_url'
:
studio_url
,
'reverifications'
:
reverifications
,
'show_enroll_banner'
:
show_enroll_banner
,
'url_to_enroll'
:
url_to_enroll
,
}
now
=
datetime
.
now
(
UTC
())
effective_start
=
_adjust_start_date_for_beta_testers
(
request
.
user
,
course
,
course_key
)
if
staff_access
and
now
<
effective_start
:
# Disable student view button if user is staff and
# course is not yet visible to students.
context
[
'disable_student_access'
]
=
True
now
=
datetime
.
now
(
UTC
())
effective_start
=
_adjust_start_date_for_beta_testers
(
request
.
user
,
course
,
course_key
)
if
staff_access
and
now
<
effective_start
:
# Disable student view button if user is staff and
# course is not yet visible to students.
context
[
'disable_student_access'
]
=
True
return
render_to_response
(
'courseware/info.html'
,
context
)
return
render_to_response
(
'courseware/info.html'
,
context
)
@ensure_csrf_cookie
...
...
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