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
5a2b2e01
Commit
5a2b2e01
authored
Jul 03, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add an index page that lists all courses
parent
a5d861d2
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
0 deletions
+62
-0
cms/djangoapps/contentstore/views.py
+15
-0
cms/templates/index.html
+12
-0
common/lib/xmodule/xmodule/modulestore/__init__.py
+12
-0
common/lib/xmodule/xmodule/modulestore/mongo.py
+23
-0
No files found.
cms/djangoapps/contentstore/views.py
View file @
5a2b2e01
...
...
@@ -3,12 +3,27 @@ import json
from
django.http
import
HttpResponse
from
django_future.csrf
import
ensure_csrf_cookie
from
fs.osfs
import
OSFS
from
django.core.urlresolvers
import
reverse
from
mitxmako.shortcuts
import
render_to_response
from
xmodule.modulestore.django
import
modulestore
@ensure_csrf_cookie
def
index
(
request
):
courses
=
modulestore
()
.
get_items
([
'i4x'
,
None
,
None
,
'course'
,
None
])
print
courses
return
render_to_response
(
'index.html'
,
{
'courses'
:
[(
course
.
metadata
[
'display_name'
],
reverse
(
'course_index'
,
args
=
[
course
.
location
.
org
,
course
.
location
.
course
,
course
.
location
.
name
]))
for
course
in
courses
]
})
@ensure_csrf_cookie
def
course_index
(
request
,
org
,
course
,
name
):
# TODO (cpennington): These need to be read in from the active user
course
=
modulestore
()
.
get_item
([
'i4x'
,
org
,
course
,
'course'
,
name
])
...
...
cms/templates/index.html
0 → 100644
View file @
5a2b2e01
<
%
inherit
file=
"base.html"
/>
<
%
block
name=
"title"
>
Courses
</
%
block>
<
%
block
name=
"content"
>
<section
class=
"main-container"
>
<ol>
%for course, url in courses:
<li><a
href=
"${url}"
>
${course}
</a></li>
%endfor
</ol>
</section>
</
%
block>
common/lib/xmodule/xmodule/modulestore/__init__.py
View file @
5a2b2e01
...
...
@@ -154,6 +154,18 @@ class ModuleStore(object):
"""
raise
NotImplementedError
def
get_items
(
self
,
location
,
default_class
=
None
):
"""
Returns a list of XModuleDescriptor instances for the items
that match location. Any element of location that is None is treated
as a wildcard that matches any value
location: Something that can be passed to Location
default_class: An XModuleDescriptor subclass to use if no plugin matching the
location is found
"""
raise
NotImplementedError
# TODO (cpennington): Replace with clone_item
def
create_item
(
self
,
location
,
editor
):
raise
NotImplementedError
...
...
common/lib/xmodule/xmodule/modulestore/mongo.py
View file @
5a2b2e01
...
...
@@ -58,6 +58,29 @@ class MongoModuleStore(ModuleStore):
return
XModuleDescriptor
.
load_from_json
(
item
,
MakoDescriptorSystem
(
load_item
=
self
.
get_item
,
resources_fs
=
None
,
render_template
=
render_to_string
),
self
.
default_class
)
def
get_items
(
self
,
location
,
default_class
=
None
):
query
=
{}
for
key
,
val
in
Location
(
location
)
.
dict
()
.
iteritems
():
if
val
is
not
None
:
query
[
'location.{key}'
.
format
(
key
=
key
)]
=
val
items
=
self
.
collection
.
find
(
query
,
sort
=
[(
'revision'
,
pymongo
.
ASCENDING
)],
)
# TODO (cpennington): Pass a proper resources_fs to the system
system
=
MakoDescriptorSystem
(
load_item
=
self
.
get_item
,
resources_fs
=
None
,
render_template
=
render_to_string
)
return
[
XModuleDescriptor
.
load_from_json
(
item
,
system
,
self
.
default_class
)
for
item
in
items
]
def
create_item
(
self
,
location
):
"""
Create an empty item at the specified location with the supplied editor
...
...
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