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
ba5a854c
Commit
ba5a854c
authored
Jul 16, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pep8 cleanup on contentstore.views
parent
f2ecab2c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
cms/djangoapps/contentstore/views.py
+12
-6
No files found.
cms/djangoapps/contentstore/views.py
View file @
ba5a854c
...
@@ -6,7 +6,6 @@ from django.contrib.auth.decorators import login_required
...
@@ -6,7 +6,6 @@ from django.contrib.auth.decorators import login_required
from
django.core.context_processors
import
csrf
from
django.core.context_processors
import
csrf
from
django_future.csrf
import
ensure_csrf_cookie
from
django_future.csrf
import
ensure_csrf_cookie
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
fs.osfs
import
OSFS
from
xmodule.modulestore
import
Location
from
xmodule.modulestore
import
Location
from
xmodule.x_module
import
ModuleSystem
from
xmodule.x_module
import
ModuleSystem
...
@@ -16,6 +15,7 @@ from static_replace import replace_urls
...
@@ -16,6 +15,7 @@ from static_replace import replace_urls
from
mitxmako.shortcuts
import
render_to_response
,
render_to_string
from
mitxmako.shortcuts
import
render_to_response
,
render_to_string
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
# ==== Public views ==================================================
# ==== Public views ==================================================
@ensure_csrf_cookie
@ensure_csrf_cookie
...
@@ -24,7 +24,8 @@ def signup(request):
...
@@ -24,7 +24,8 @@ def signup(request):
Display the signup form.
Display the signup form.
"""
"""
csrf_token
=
csrf
(
request
)[
'csrf_token'
]
csrf_token
=
csrf
(
request
)[
'csrf_token'
]
return
render_to_response
(
'signup.html'
,
{
'csrf'
:
csrf_token
})
return
render_to_response
(
'signup.html'
,
{
'csrf'
:
csrf_token
})
@ensure_csrf_cookie
@ensure_csrf_cookie
def
login_page
(
request
):
def
login_page
(
request
):
...
@@ -32,8 +33,9 @@ def login_page(request):
...
@@ -32,8 +33,9 @@ def login_page(request):
Display the login form.
Display the login form.
"""
"""
csrf_token
=
csrf
(
request
)[
'csrf_token'
]
csrf_token
=
csrf
(
request
)[
'csrf_token'
]
return
render_to_response
(
'login.html'
,
{
'csrf'
:
csrf_token
})
return
render_to_response
(
'login.html'
,
{
'csrf'
:
csrf_token
})
# ==== Views for any logged-in user ==================================
# ==== Views for any logged-in user ==================================
@login_required
@login_required
...
@@ -52,6 +54,7 @@ def index(request):
...
@@ -52,6 +54,7 @@ def index(request):
for
course
in
courses
]
for
course
in
courses
]
})
})
# ==== Views with per-item permissions================================
# ==== Views with per-item permissions================================
def
has_access
(
user
,
location
):
def
has_access
(
user
,
location
):
...
@@ -59,6 +62,7 @@ def has_access(user, location):
...
@@ -59,6 +62,7 @@ def has_access(user, location):
# TODO (vshnayder): actually check perms
# TODO (vshnayder): actually check perms
return
user
.
is_active
and
user
.
is_authenticated
return
user
.
is_active
and
user
.
is_authenticated
@login_required
@login_required
@ensure_csrf_cookie
@ensure_csrf_cookie
def
course_index
(
request
,
org
,
course
,
name
):
def
course_index
(
request
,
org
,
course
,
name
):
...
@@ -70,12 +74,13 @@ def course_index(request, org, course, name):
...
@@ -70,12 +74,13 @@ def course_index(request, org, course, name):
location
=
[
'i4x'
,
org
,
course
,
'course'
,
name
]
location
=
[
'i4x'
,
org
,
course
,
'course'
,
name
]
if
not
has_access
(
request
.
user
,
location
):
if
not
has_access
(
request
.
user
,
location
):
raise
Http404
# TODO (vshnayder): better error
raise
Http404
# TODO (vshnayder): better error
# TODO (cpennington): These need to be read in from the active user
# TODO (cpennington): These need to be read in from the active user
course
=
modulestore
()
.
get_item
(
location
)
course
=
modulestore
()
.
get_item
(
location
)
weeks
=
course
.
get_children
()
weeks
=
course
.
get_children
()
return
render_to_response
(
'course_index.html'
,
{
'weeks'
:
weeks
})
return
render_to_response
(
'course_index.html'
,
{
'weeks'
:
weeks
})
@login_required
@login_required
def
edit_item
(
request
):
def
edit_item
(
request
):
"""
"""
...
@@ -90,7 +95,7 @@ def edit_item(request):
...
@@ -90,7 +95,7 @@ def edit_item(request):
print
item_location
,
request
.
GET
print
item_location
,
request
.
GET
if
not
has_access
(
request
.
user
,
item_location
):
if
not
has_access
(
request
.
user
,
item_location
):
raise
Http404
# TODO (vshnayder): better error
raise
Http404
# TODO (vshnayder): better error
item
=
modulestore
()
.
get_item
(
item_location
)
item
=
modulestore
()
.
get_item
(
item_location
)
return
render_to_response
(
'unit.html'
,
{
return
render_to_response
(
'unit.html'
,
{
'contents'
:
item
.
get_html
(),
'contents'
:
item
.
get_html
(),
...
@@ -116,6 +121,7 @@ def user_author_string(user):
...
@@ -116,6 +121,7 @@ def user_author_string(user):
last
=
l
,
last
=
l
,
email
=
user
.
email
)
email
=
user
.
email
)
@login_required
@login_required
def
preview_dispatch
(
request
,
module_id
,
dispatch
):
def
preview_dispatch
(
request
,
module_id
,
dispatch
):
"""
"""
...
...
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