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
28a2dd9a
Commit
28a2dd9a
authored
Jan 28, 2013
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support reordering of static tabs in studio
parent
163400e2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
3 deletions
+55
-3
cms/djangoapps/contentstore/views.py
+39
-2
cms/static/coffee/src/views/tabs.coffee
+15
-1
cms/urls.py
+1
-0
No files found.
cms/djangoapps/contentstore/views.py
View file @
28a2dd9a
...
@@ -903,6 +903,36 @@ def static_pages(request, org, course, coursename):
...
@@ -903,6 +903,36 @@ def static_pages(request, org, course, coursename):
def
edit_static
(
request
,
org
,
course
,
coursename
):
def
edit_static
(
request
,
org
,
course
,
coursename
):
return
render_to_response
(
'edit-static-page.html'
,
{})
return
render_to_response
(
'edit-static-page.html'
,
{})
@login_required
@expect_json
def
reorder_tabs
(
request
):
tabs
=
request
.
POST
[
'tabs'
]
logging
.
debug
(
'tabs = {0} {1}'
.
format
(
tabs
.
__class__
,
tabs
))
if
len
(
tabs
)
>
0
:
course
=
get_course_for_item
(
tabs
[
0
])
if
not
has_access
(
request
.
user
,
course
.
location
):
raise
PermissionDenied
()
# first filter out all non-static tabs from the tabs list
course_tabs
=
[
t
for
t
in
course
.
tabs
if
t
[
'type'
]
!=
'static_tab'
]
# OK, re-assemble the static tabs in the new order
for
tab
in
tabs
:
item
=
modulestore
(
'direct'
)
.
get_item
(
Location
(
tab
))
course_tabs
.
append
({
'type'
:
'static_tab'
,
'name'
:
item
.
metadata
.
get
(
'display_name'
),
'url_slug'
:
item
.
location
.
name
}
)
course
.
tabs
=
course_tabs
modulestore
(
'direct'
)
.
update_metadata
(
course
.
location
,
course
.
metadata
)
return
HttpResponse
()
@login_required
@login_required
@ensure_csrf_cookie
@ensure_csrf_cookie
def
edit_tabs
(
request
,
org
,
course
,
coursename
):
def
edit_tabs
(
request
,
org
,
course
,
coursename
):
...
@@ -914,12 +944,19 @@ def edit_tabs(request, org, course, coursename):
...
@@ -914,12 +944,19 @@ def edit_tabs(request, org, course, coursename):
if
not
has_access
(
request
.
user
,
location
):
if
not
has_access
(
request
.
user
,
location
):
raise
PermissionDenied
()
raise
PermissionDenied
()
static_tabs
=
modulestore
(
'direct'
)
.
get_items
(
static_tabs_loc
)
# see tabs have been uninitialized (e.g. supporing courses created before tab support in studio)
# see tabs have been uninitialized (e.g. supporing courses created before tab support in studio)
if
course_item
.
tabs
is
None
or
len
(
course_item
.
tabs
)
==
0
:
if
course_item
.
tabs
is
None
or
len
(
course_item
.
tabs
)
==
0
:
initialize_course_tabs
(
course_item
)
initialize_course_tabs
(
course_item
)
# first get all static tabs from the tabs list
# we do this because this is also the order in which items are displayed in the LMS
static_tabs_refs
=
[
t
for
t
in
course_item
.
tabs
if
t
[
'type'
]
==
'static_tab'
]
static_tabs
=
[]
for
static_tab_ref
in
static_tabs_refs
:
static_tab_loc
=
Location
(
location
)
.
_replace
(
category
=
'static_tab'
,
name
=
static_tab_ref
[
'url_slug'
])
static_tabs
.
append
(
modulestore
(
'direct'
)
.
get_item
(
static_tab_loc
))
components
=
[
components
=
[
static_tab
.
location
.
url
()
static_tab
.
location
.
url
()
for
static_tab
for
static_tab
...
...
cms/static/coffee/src/views/tabs.coffee
View file @
28a2dd9a
...
@@ -15,7 +15,7 @@ class CMS.Views.TabsEdit extends Backbone.View
...
@@ -15,7 +15,7 @@ class CMS.Views.TabsEdit extends Backbone.View
@
$
(
'.components'
).
sortable
(
@
$
(
'.components'
).
sortable
(
handle
:
'.drag-handle'
handle
:
'.drag-handle'
update
:
(
event
,
ui
)
=>
alert
'not yet implemented!'
update
:
@
tabMoved
helper
:
'clone'
helper
:
'clone'
opacity
:
'0.5'
opacity
:
'0.5'
placeholder
:
'component-placeholder'
placeholder
:
'component-placeholder'
...
@@ -24,6 +24,20 @@ class CMS.Views.TabsEdit extends Backbone.View
...
@@ -24,6 +24,20 @@ class CMS.Views.TabsEdit extends Backbone.View
items
:
'> .component'
items
:
'> .component'
)
)
tabMoved
:
(
event
,
ui
)
=>
tabs
=
[]
@
$
(
'.component'
).
each
((
idx
,
element
)
=>
tabs
.
push
(
$
(
element
).
data
(
'id'
))
)
$
.
ajax
({
type
:
'POST'
,
url
:
'/reorder_tabs'
,
data
:
JSON
.
stringify
({
tabs
:
tabs
}),
contentType
:
'application/json'
})
addNewTab
:
(
event
)
=>
addNewTab
:
(
event
)
=>
event
.
preventDefault
()
event
.
preventDefault
()
...
...
cms/urls.py
View file @
28a2dd9a
...
@@ -17,6 +17,7 @@ urlpatterns = ('',
...
@@ -17,6 +17,7 @@ urlpatterns = ('',
url
(
r'^publish_draft$'
,
'contentstore.views.publish_draft'
,
name
=
'publish_draft'
),
url
(
r'^publish_draft$'
,
'contentstore.views.publish_draft'
,
name
=
'publish_draft'
),
url
(
r'^unpublish_unit$'
,
'contentstore.views.unpublish_unit'
,
name
=
'unpublish_unit'
),
url
(
r'^unpublish_unit$'
,
'contentstore.views.unpublish_unit'
,
name
=
'unpublish_unit'
),
url
(
r'^create_new_course'
,
'contentstore.views.create_new_course'
,
name
=
'create_new_course'
),
url
(
r'^create_new_course'
,
'contentstore.views.create_new_course'
,
name
=
'create_new_course'
),
url
(
r'^reorder_tabs'
,
'contentstore.views.reorder_tabs'
,
name
=
'reorder_tabs'
),
url
(
r'^(?P<org>[^/]+)/(?P<course>[^/]+)/course/(?P<name>[^/]+)$'
,
url
(
r'^(?P<org>[^/]+)/(?P<course>[^/]+)/course/(?P<name>[^/]+)$'
,
'contentstore.views.course_index'
,
name
=
'course_index'
),
'contentstore.views.course_index'
,
name
=
'course_index'
),
...
...
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