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
0d63d0c1
Commit
0d63d0c1
authored
Aug 18, 2014
by
Daniel Friedman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provide course outline template with start date
parent
70d47fb5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
0 deletions
+42
-0
cms/djangoapps/contentstore/views/course.py
+6
-0
cms/djangoapps/contentstore/views/tests/test_course_index.py
+35
-0
cms/templates/course_outline.html
+1
-0
No files found.
cms/djangoapps/contentstore/views/course.py
View file @
0d63d0c1
...
...
@@ -16,8 +16,10 @@ from django.core.exceptions import PermissionDenied
from
django.core.urlresolvers
import
reverse
from
django.http
import
HttpResponseBadRequest
,
HttpResponseNotFound
,
HttpResponse
from
util.json_request
import
JsonResponse
from
util.date_utils
import
get_default_time_display
from
edxmako.shortcuts
import
render_to_response
from
xmodule.course_module
import
DEFAULT_START_DATE
from
xmodule.error_module
import
ErrorDescriptor
from
xmodule.modulestore.django
import
modulestore
from
xmodule.contentstore.content
import
StaticContent
...
...
@@ -376,6 +378,8 @@ def course_index(request, course_key):
sections
=
course_module
.
get_children
()
course_structure
=
_course_outline_json
(
request
,
course_module
)
locator_to_show
=
request
.
REQUEST
.
get
(
'show'
,
None
)
course_release_date
=
get_default_time_display
(
course_module
.
start
)
if
course_module
.
start
!=
DEFAULT_START_DATE
else
_
(
"Unscheduled"
)
settings_url
=
reverse_course_url
(
'settings_handler'
,
course_key
)
try
:
current_action
=
CourseRerunState
.
objects
.
find_first
(
course_key
=
course_key
,
should_display
=
True
)
...
...
@@ -392,6 +396,8 @@ def course_index(request, course_key):
CourseGradingModel
.
fetch
(
course_key
)
.
graders
),
'rerun_notification_id'
:
current_action
.
id
if
current_action
else
None
,
'course_release_date'
:
course_release_date
,
'settings_url'
:
settings_url
,
})
...
...
cms/djangoapps/contentstore/views/tests/test_course_index.py
View file @
0d63d0c1
...
...
@@ -3,6 +3,7 @@ Unit tests for getting the list of courses and the course outline.
"""
import
json
import
lxml
import
datetime
from
contentstore.tests.utils
import
CourseTestCase
from
contentstore.utils
import
reverse_course_url
,
add_instructor
...
...
@@ -10,6 +11,8 @@ from contentstore.views.access import has_course_access
from
contentstore.views.course
import
course_outline_initial_state
from
contentstore.views.item
import
create_xblock_info
,
VisibilityState
from
course_action_state.models
import
CourseRerunState
from
util.date_utils
import
get_default_time_display
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
opaque_keys.edx.locator
import
CourseLocator
...
...
@@ -273,3 +276,35 @@ class TestCourseOutline(CourseTestCase):
expanded_locators
=
initial_state
[
'expanded_locators'
]
self
.
assertIn
(
unicode
(
self
.
sequential
.
location
),
expanded_locators
)
self
.
assertIn
(
unicode
(
self
.
vertical
.
location
),
expanded_locators
)
def
test_start_date_on_page
(
self
):
"""
Verify that the course start date is included on the course outline page.
"""
def
_get_release_date
(
response
):
"""Return the release date from the course page"""
parsed_html
=
lxml
.
html
.
fromstring
(
response
.
content
)
return
parsed_html
.
find_class
(
'course-status'
)[
0
]
.
find_class
(
'status-release-value'
)[
0
]
.
text_content
()
def
_assert_settings_link_present
(
response
):
"""
Asserts there's a course settings link on the course page by the course release date.
"""
parsed_html
=
lxml
.
html
.
fromstring
(
response
.
content
)
settings_link
=
parsed_html
.
find_class
(
'course-status'
)[
0
]
.
find_class
(
'action-edit'
)[
0
]
.
find
(
'a'
)
self
.
assertIsNotNone
(
settings_link
)
self
.
assertEqual
(
settings_link
.
get
(
'href'
),
reverse_course_url
(
'settings_handler'
,
self
.
course
.
id
))
outline_url
=
reverse_course_url
(
'course_handler'
,
self
.
course
.
id
)
response
=
self
.
client
.
get
(
outline_url
,
{},
HTTP_ACCEPT
=
'text/html'
)
# A course with the default release date should display as "Unscheduled"
self
.
assertEqual
(
_get_release_date
(
response
),
'Unscheduled'
)
_assert_settings_link_present
(
response
)
self
.
course
.
start
=
datetime
.
datetime
(
2014
,
1
,
1
)
modulestore
()
.
update_item
(
self
.
course
,
ModuleStoreEnum
.
UserID
.
test
)
response
=
self
.
client
.
get
(
outline_url
,
{},
HTTP_ACCEPT
=
'text/html'
)
self
.
assertEqual
(
_get_release_date
(
response
),
get_default_time_display
(
self
.
course
.
start
))
_assert_settings_link_present
(
response
)
cms/templates/course_outline.html
View file @
0d63d0c1
...
...
@@ -42,6 +42,7 @@ from contentstore.utils import reverse_usage_url
<h1
class=
"page-header"
>
<small
class=
"subtitle"
>
${_("Content")}
</small>
<span
class=
"sr"
>
>
</span>
${_("Course Outline")}
<span><a
href=
"${settings_url}"
>
${course_release_date}
</a></span>
</h1>
<nav
class=
"nav-actions"
>
...
...
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