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
f1ba26b0
Commit
f1ba26b0
authored
Aug 03, 2012
by
ichuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
require login and enrollment in course to be able to view its courseware
parent
84ed806f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
lms/djangoapps/courseware/views.py
+14
-5
No files found.
lms/djangoapps/courseware/views.py
View file @
f1ba26b0
...
@@ -150,6 +150,7 @@ def render_accordion(request, course, chapter, section):
...
@@ -150,6 +150,7 @@ def render_accordion(request, course, chapter, section):
return
render_to_string
(
'accordion.html'
,
context
)
return
render_to_string
(
'accordion.html'
,
context
)
@login_required
@ensure_csrf_cookie
@ensure_csrf_cookie
@cache_control
(
no_cache
=
True
,
no_store
=
True
,
must_revalidate
=
True
)
@cache_control
(
no_cache
=
True
,
no_store
=
True
,
must_revalidate
=
True
)
def
index
(
request
,
course_id
,
chapter
=
None
,
section
=
None
,
def
index
(
request
,
course_id
,
chapter
=
None
,
section
=
None
,
...
@@ -172,6 +173,10 @@ def index(request, course_id, chapter=None, section=None,
...
@@ -172,6 +173,10 @@ def index(request, course_id, chapter=None, section=None,
- HTTPresponse
- HTTPresponse
'''
'''
course
=
check_course
(
course_id
)
course
=
check_course
(
course_id
)
registered
=
registered_for_course
(
course
,
request
.
user
)
if
not
registered
:
log
.
debug
(
'User
%
s tried to view course
%
s but is not enrolled'
%
(
request
.
user
,
course
.
location
.
url
()))
return
redirect
(
'/'
)
try
:
try
:
context
=
{
context
=
{
...
@@ -266,14 +271,18 @@ def course_info(request, course_id):
...
@@ -266,14 +271,18 @@ def course_info(request, course_id):
return
render_to_response
(
'info.html'
,
{
'course'
:
course
})
return
render_to_response
(
'info.html'
,
{
'course'
:
course
})
def
registered_for_course
(
course
,
user
):
'''Return CourseEnrollment if user is registered for course, else False'''
if
user
is
None
:
return
False
if
user
.
is_authenticated
():
return
CourseEnrollment
.
objects
.
filter
(
user
=
user
,
course_id
=
course
.
id
)
.
exists
()
else
:
return
False
@ensure_csrf_cookie
@ensure_csrf_cookie
@cache_if_anonymous
@cache_if_anonymous
def
course_about
(
request
,
course_id
):
def
course_about
(
request
,
course_id
):
def
registered_for_course
(
course
,
user
):
if
user
.
is_authenticated
():
return
CourseEnrollment
.
objects
.
filter
(
user
=
user
,
course_id
=
course
.
id
)
.
exists
()
else
:
return
False
course
=
check_course
(
course_id
,
course_must_be_open
=
False
)
course
=
check_course
(
course_id
,
course_must_be_open
=
False
)
registered
=
registered_for_course
(
course
,
request
.
user
)
registered
=
registered_for_course
(
course
,
request
.
user
)
return
render_to_response
(
'portal/course_about.html'
,
{
'course'
:
course
,
'registered'
:
registered
})
return
render_to_response
(
'portal/course_about.html'
,
{
'course'
:
course
,
'registered'
:
registered
})
...
...
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